package com.car.web.controller.interfaceController;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.car.dal.dao.goods.*;
import com.car.dal.dao.grade.TgUsergradeDao;
import com.car.dal.dao.method.TgMethodDao;
import com.car.dal.object.*;
import com.car.util.*;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.log4j.Logger;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.CellRangeAddress;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.CellStyle;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.car.dal.dao.ask.AskDao;
import com.car.dal.dao.cj.ChouJiangDao;
import com.car.dal.dao.client.TgClientDao;
import com.car.dal.dao.moneys.TgMoneyDao;
import com.car.dal.dao.office.TgOfficeDao;
import com.car.dal.dao.period.TgPeriodDao;
import com.car.dal.dao.personnel.PersonnelStateDao;
import com.car.dal.dao.pos.TgPosDao;
import com.car.dal.dao.quit.QuitDao;
import com.car.dal.dao.reception.TgReceptionDao;
import com.car.dal.dao.recruitment.GoodProvideDao;
import com.car.dal.dao.recruitment.RecruitmentDao;
import com.car.dal.dao.recruitment.RecruitmentResultDao;
import com.car.dal.dao.reserve.TgReserveDao;
import com.car.dal.dao.sudent.StudentDao;
import com.car.dal.dao.teacher.TeacherDao;
import com.car.dal.dao.turnover.TgTurnoverDao;
import com.car.dal.dao.user.UserDao;
import com.car.dal.dao.user.UserinfoDao;
import com.car.dal.dao.vote.JsVoteDao;
import com.car.exception.BaseException;
import com.car.service.TgTurnover.TgTurnoverService;
import com.car.service.reception.ReceptionService;
import com.car.service.tgPeriod.TgPeriodService;
import com.car.util.JsonExecutor.JsonBiz;
import com.car.util.WebExecutor.Biz;
import com.car.util.upload_download_for_ftp.SFTPUtil;
import com.car.web.controller.base.BaseController;
import com.car.web.controller.base.BaseVo;
import com.car.web.controller.index.LoginVo;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.jcraft.jsch.SftpException;
import com.jcraft.jsch.UserAuthGSSAPIWithMIC;
import com.ssi.utils.SsiUtils;

/**
 * 登录控制
 * 
 * @author Administrator
 * 
 */
@Controller
@RequestMapping("/oa")
public class InterfaceController extends BaseController {
	private static final Logger logger = Logger.getLogger(InterfaceController.class);
	private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
	private static SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	@Resource
	private AskDao askDao;
	@Resource
	private JsVoteDao voteDao;
	@Resource
	private JsVoteDao jsVoteDao;
	@Resource
	private TgReserveDao reserveDao;
	@Resource
	private TgClientDao clientDao;
	@Resource
	private StudentDao studentDao;
	@Resource
	private UserinfoDao userinfoDao;
	@Resource
	private TgReceptionDao receptionDao;
	@Resource
	private TgMoneyDao moneyDao;
	@Resource
	private TgPosDao posDao;
	@Resource
	private TgOfficeDao tgOfficeDao;
	@Resource
	private TgGoodsDao goodsDao;
	@Resource
	private TgGoodsAccountDao tgGoodsAccountDao;
	@Resource
	private TgGoodsKeyDao tgGoodKeyDao;
	@Resource
	private TgUsergradeDao usergradeDao;
	@Resource
	private UserDao userDao;
	@Resource
	private UserinfoDao userInfoDao;
	@Resource
	private ReceptionService receptionService;
	@Resource
	private TgPeriodService tgPeriodService;
	@Resource
	private TgPeriodDao tgPeriodDao;
	@Resource
	private TgTurnoverService tgTurnoverService;
	@Resource
	private TgTurnoverDao tgTurnoverDao;
	@Resource
	private PersonnelStateDao personnelStateDao;
	@Resource
	private RecruitmentResultDao recruitmentResultDao;
	@Resource
	private RecruitmentDao recruitmentDao;
	@Resource
	private QuitDao quitDao;
	@Resource
	private GoodProvideDao goodProvideDao;
	@Resource
	private ChouJiangDao cjDao;
	@Resource
	private TgMethodDao methodDao;
	@Resource
    private GoodsMnusDao goodsMnusDao;
	@Resource
    private GoodsNewDao goodsNewDao;
	@Resource
	private GoodsServiceDao goodsServiceDao;
	@Resource
	private GoodsServiceDetailDao goodsServiceDetailDao;
	// 网站调查，表单提交
	@RequestMapping(value = "/from_user_add")
	public ModelAndView from_user_add(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String type = request.getParameter("type");
				String name = request.getParameter("name");
				String age = request.getParameter("age");
				String phone = request.getParameter("phone");
				String email = request.getParameter("email");
				String city = request.getParameter("city");
				String url = request.getParameter("url");
				String ip = request.getParameter("ip");
				String school = request.getParameter("school");

				if (phone == null && "null".equals(phone) && "".equals(phone)) {
					return result;
				}

				String source = "";
				if (type != null) {
					if (("严马，宋子豪，陈涵").contains(type)) {
						source = "8yjy5cw5w5x0";
					} else if (("移动网盟-杭州，PC网盟-杭州").contains(type)) {
						source = "251mokab1mtn";
					} else if (("注意力专题预约-广州、多动症专题预约-广州、阅读障碍专题预约-广州、阅读障碍专题预约-杭州、注意力专题预约-杭州、多动症专题预约-杭州").contains(type)) {
						source = "775F42F3B3B6";
					} else if (("手机体验课报名-广州、预约免费课-杭州、体验课报名-杭州、体验课报名-广州").contains(type)) {
						source = "13b6lzltt0xk";
					} else if (("VIP太优体验课、太优体验课免费预约、寒假集训预约、注意力免费体验课、市场部：公益讲座注意力测评报名、市场部预约").contains(type)) {
						source = "ct5yq4jhc6c7";
					}
				}

				JsVote fromUser = new JsVote();
				List<JsVote> fromelist = null;
				int from_cn = 0;
				if (phone != null && phone != "") {
					fromUser.setPhone(phone);
					fromelist = jsVoteDao.findByExample(fromUser);
					if (fromelist != null && fromelist.size() > 0) {
						from_cn = fromelist.size();
					}
					//判断当天改电话只能有一条数据
					try {
						long cdate_start = sdf.parse(sdf.format(new Date())).getTime()/1000;
						long cdate_end = DateUtil.getTommorrowDay_Ms()/1000;
						Integer count = jsVoteDao.getNowDayCount_ByPhone(phone, cdate_start,cdate_end);
						if(count >= 1) {
							result.setDefaultModel("flag", "您当天已经有过一个预约了");
							return result;
						}
					} catch (ParseException e) {e.printStackTrace();}
				}
				fromUser.setFrom_cn(from_cn);
				fromUser.setType(type);
				fromUser.setName(name);
				fromUser.setAge(age);
				fromUser.setSource(source);
				fromUser.setIp(ip);
				fromUser.setPhone(phone);
				fromUser.setEmail(email);
				fromUser.setCity(city);
				fromUser.setUrl(url);
				fromUser.setSchool(school);
				fromUser.setCdate(new Date().getTime() / 1000);
				fromUser.setSourceTable(2);
				jsVoteDao.insert(fromUser);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 测试页面
	@RequestMapping(value = "/zice")
	public ModelAndView zice(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, vo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				return result;
			}
		});
		return new ModelAndView("/taiyou/zice", modelMap);
	}

	@RequestMapping(value = "/wenjuan")
	public ModelAndView wenjuan(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, vo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				return result;
			}
		});
		return new ModelAndView("/taiyou/wenjuan", modelMap);
	}

	// 跨域
	@RequestMapping(value = "adds")
	public Map<String, Object> listTeacherTree(ModelMap model, HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, Object> ms = new HashMap<String, Object>();
		String answer = request.getParameter("answer");
		String key = request.getParameter("key");
		String spcode = request.getParameter("spcode");
		String age = request.getParameter("age");
		String ip = request.getParameter("ip");
		String phone = request.getParameter("phone");
		String city = request.getParameter("city");
		String url = request.getParameter("url");

		ms.put("answer", answer);
		// 保存到数据库vote表中去
		JsVote vote = new JsVote();
		String vokey = SsiUtils.randomUUID().substring(0, 5);
		if (answer != null && !"".equals(answer)) {
			byte[] srtbyte = null;
			try {
				srtbyte = answer.getBytes("UTF-8");
				String bytess = StringUtil.toHex(srtbyte);
				vote.setAnswer(bytess);
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		if (age != null && !"".equals(age)) {
			vote.setAge(age);
		}
		vote.setAsk(key);
		vote.setUrl(url);
		vote.setCity(city);
		vote.setPhone(phone);
		vote.setSpcode(spcode);
		vote.setKeyname(vokey);
		vote.setIp(ip);
		vote.setCdate(new Date().getTime() / 1000);
		voteDao.insert(vote);

		// 这里查询ask表中的评分
		JsAsk ask = new JsAsk();
		ask.setKeyname(key);
		List<JsAsk> aslist = askDao.findByExample(ask);
		String score = "";
		if (aslist != null && aslist.size() > 0) {
			score = aslist.get(0).getScore();

			if (score != null && !"".equals(score)) {
				try {
					List<AskMsg> askSList = new ArrayList<AskMsg>();

					JSONObject obj = JSONObject.fromObject(score);

					for (int j = 0; j < 15; j++) {
						JSONObject ask0 = obj.getJSONObject("ask" + j);
						if (ask0 != null && !"null".equals(ask0) && ask0.toString().length() > 10) {
							String id = ask0.getString("id");
							String topic = ask0.getString("topic");
							JSONArray source = ask0.getJSONArray("source");
							JSONArray scores = ask0.getJSONArray("scores");
							AskMsg askMsg = new AskMsg();
							askMsg.setId(id);
							askMsg.setTopic(topic);
							askMsg.setSource(source);
							if (scores != null && scores.size() > 0) {
								List<Scores> scoresList = new ArrayList<Scores>();
								for (int i = 0; i < scores.size(); i++) {
									Scores sco = new Scores();
									JSONObject o = JSONObject.fromObject(scores.get(i));
									sco.setS1(o.getString("s1"));
									sco.setS2(o.getString("s2"));
									sco.setR(o.getString("r"));
									scoresList.add(sco);
								}
								askMsg.setScoresList(scoresList);
							}
							askSList.add(askMsg);
						}
					}
					ms.put("askSList", askSList);

				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}

		// 查询问卷数据
		vote.setKeyname(vokey);
		List<JsVote> volist = voteDao.findByExample(vote);
		vote = volist.get(0);
		if (vote.getAnswer() != null && !"".equals(vote.getAnswer())) {
			boolean flag = StringUtil.getHanzi(vote.getAnswer());
			if (!flag) {
				try {
					byte[] bytes = StringUtil.hexDecode(vote.getAnswer());
					String ObjContent = new String(bytes, "UTF-8");
					vote.setAnswer(ObjContent);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}

		ms.put("aslist", aslist);
		ms.put("answer", answer);
		ms.put("volist", volist);
		ms.put("key", vokey);

		try {
			request.setCharacterEncoding("utf-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}

		response.setContentType("text/html;charset=utf-8");

		JSONObject resultJSON = JSONObject.fromObject(ms); // 根据需要拼装json
		String jsonpCallback = request.getParameter("callback");// 客户端请求参数
		OutputStream ouputStream;
		try {
			ouputStream = response.getOutputStream();
			ouputStream.write((jsonpCallback + "(" + resultJSON.toString() + ")").getBytes());
			ouputStream.flush();
			ouputStream.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return ms;
	}

	// 异步添加测评信息
	@RequestMapping(value = "/add_vote")
	public ModelAndView add_vote(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);

				String answer = request.getParameter("answer");
				String key = request.getParameter("key");
				String spcode = request.getParameter("spcode");
				String age = request.getParameter("age");
				String ip = request.getParameter("ip");
				String phone = request.getParameter("phone");
				String city = request.getParameter("city");
				// 保存到数据库vote表中去
				JsVote vote = new JsVote();
				String vokey = SsiUtils.randomUUID().substring(0, 5);
				if (answer != null && !"".equals(answer)) {
					byte[] srtbyte = null;
					try {
						srtbyte = answer.getBytes("UTF-8");
						String bytess = StringUtil.toHex(srtbyte);
						vote.setAnswer(bytess);
					} catch (UnsupportedEncodingException e) {
						e.printStackTrace();
					}
				}
				if (age != null && !"".equals(age)) {
					vote.setAge(age);
				}
				vote.setAsk(key);
				vote.setCity(city);
				vote.setPhone(phone);
				vote.setSpcode(spcode);
				vote.setKeyname(vokey);
				vote.setCdate(new Date().getTime() / 1000);
				voteDao.insert(vote);

				// 这里查询ask表中的评分
				JsAsk ask = new JsAsk();
				ask.setKeyname(key);
				List<JsAsk> aslist = askDao.findByExample(ask);

				String score = aslist.get(0).getScore();
				if (score != null && !"".equals(score)) {
					try {
						List<AskMsg> askSList = new ArrayList<AskMsg>();

						JSONObject obj = JSONObject.fromObject(score);

						for (int j = 0; j < 15; j++) {
							JSONObject ask0 = obj.getJSONObject("ask" + j);
							if (ask0 != null && !"null".equals(ask0) && ask0.toString().length() > 10) {
								String id = ask0.getString("id");
								String topic = ask0.getString("topic");
								JSONArray source = ask0.getJSONArray("source");
								JSONArray scores = ask0.getJSONArray("scores");
								AskMsg askMsg = new AskMsg();
								askMsg.setId(id);
								askMsg.setTopic(topic);
								askMsg.setSource(source);
								if (scores != null && scores.size() > 0) {
									List<Scores> scoresList = new ArrayList<Scores>();
									for (int i = 0; i < scores.size(); i++) {
										Scores sco = new Scores();
										JSONObject o = JSONObject.fromObject(scores.get(i));
										sco.setS1(o.getString("s1"));
										sco.setS2(o.getString("s2"));
										sco.setR(o.getString("r"));
										scoresList.add(sco);
									}
									askMsg.setScoresList(scoresList);
								}
								askSList.add(askMsg);
							}
						}
						result.setDefaultModel("askSList", askSList);

					} catch (Exception e) {
						e.printStackTrace();
					}
				}

				// 查询问卷数据
				vote.setKeyname(vokey);
				List<JsVote> volist = voteDao.findByExample(vote);
				vote = volist.get(0);
				if (vote.getAnswer() != null && !"".equals(vote.getAnswer())) {
					boolean flag = StringUtil.getHanzi(vote.getAnswer());
					if (!flag) {
						try {
							byte[] bytes = StringUtil.hexDecode(vote.getAnswer());
							String ObjContent = new String(bytes, "UTF-8");
							vote.setAnswer(ObjContent);
						} catch (Exception e) {
							e.printStackTrace();
						}
					}
				}
				result.setDefaultModel("aslist", aslist);
				result.setDefaultModel("answer", answer);
				result.setDefaultModel("volist", volist);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 根据id查询数据
	@RequestMapping(value = "zice_index")
	public Map<String, Object> indexjson(ModelMap model, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> ms = new HashMap<String, Object>();
		String ids = request.getParameter("id");
		// 保存到数据库vote表中去
		JsVote vote = new JsVote();

		vote.setId(Long.parseLong(ids.substring(4, ids.length())));
		// 这里查询ask表中的评分
		// 查询问卷数据
		List<JsVote> volist = voteDao.findByExample(vote);
		vote = volist.get(0);
		if (vote.getAnswer() != null && !"".equals(vote.getAnswer())) {
			boolean flag = StringUtil.getHanzi(vote.getAnswer());
			if (!flag) {
				try {
					byte[] bytes = StringUtil.hexDecode(vote.getAnswer());
					String ObjContent = new String(bytes, "UTF-8");
					vote.setAnswer(ObjContent);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}

		JsAsk ask = new JsAsk();
		ask.setKeyname(vote.getAsk());
		List<JsAsk> aslist = askDao.findByExample(ask);
		String score = "";
		if (aslist != null && aslist.size() > 0) {
			score = aslist.get(0).getScore();

			if (score != null && !"".equals(score)) {
				try {
					List<AskMsg> askSList = new ArrayList<AskMsg>();

					JSONObject obj = JSONObject.fromObject(score);

					for (int j = 0; j < 15; j++) {
						JSONObject ask0 = obj.getJSONObject("ask" + j);
						if (ask0 != null && !"null".equals(ask0) && ask0.toString().length() > 10) {
							String id = ask0.getString("id");
							String topic = ask0.getString("topic");
							JSONArray source = ask0.getJSONArray("source");
							JSONArray scores = ask0.getJSONArray("scores");
							AskMsg askMsg = new AskMsg();
							askMsg.setId(id);
							askMsg.setTopic(topic);
							askMsg.setSource(source);
							if (scores != null && scores.size() > 0) {
								List<Scores> scoresList = new ArrayList<Scores>();
								for (int i = 0; i < scores.size(); i++) {
									Scores sco = new Scores();
									JSONObject o = JSONObject.fromObject(scores.get(i));
									sco.setS1(o.getString("s1"));
									sco.setS2(o.getString("s2"));
									sco.setR(o.getString("r"));
									scoresList.add(sco);
								}
								askMsg.setScoresList(scoresList);
							}
							askSList.add(askMsg);
						}
					}
					ms.put("askSList", askSList);

				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}

		ms.put("aslist", aslist);
		ms.put("volist", volist);
		ms.put("answer", vote.getAnswer());

		try {
			request.setCharacterEncoding("utf-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		response.setContentType("text/html;charset=utf-8");
		JSONObject resultJSON = JSONObject.fromObject(ms); // 根据需要拼装json
		String jsonpCallback = request.getParameter("callback");// 客户端请求参数
		OutputStream ouputStream;
		try {
			ouputStream = response.getOutputStream();
			ouputStream.write((jsonpCallback + "(" + resultJSON.toString() + ")").getBytes());
			ouputStream.flush();
			ouputStream.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return ms;
	}

	// 进入异步下载页面
	@RequestMapping(value = "/reserveXz")
	public ModelAndView login(ModelMap modelMap, final LoginVo loginVo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, loginVo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String sdate = request.getParameter("sdate");
				String edate = request.getParameter("edate");
				String type = request.getParameter("type");

				TgReserve reserve = new TgReserve();

				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
				if (type != null && !"".equals(type)) {
					try {
						if (type.equals("1")) {
							if (sdate != null && !"".equals(sdate)) {
								reserve.setStart(sdf.parse(sdate).getTime() / 1000);
							}
							if (edate != null && !"".equals(edate)) {
								reserve.setDatec(sdf.parse(edate).getTime() / 1000);
							}
						} else if (type.equals("2")) {
							if (sdate != null && !"".equals(sdate)) {
								reserve.setSdate(sdf.parse(sdate));
							}
							if (edate != null && !"".equals(edate)) {
								reserve.setEdate(sdf.parse(edate));
							}
						}
					} catch (ParseException e) {
						e.printStackTrace();
					}

					List<TgReserve> list = reserveDao.getReserve(reserve);
					if (list != null && list.size() > 0) {
						for (TgReserve res : list) {
							if (res.getCdate() != null && !"".equals(res.getCdate())) {
								SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
								String cdate = sdf1.format(new Date(res.getCdate() * 1000));
								res.setStartTime(cdate);
							}
						}
					}
					// 下载到exl
					result.setDefaultModel("sdate", sdate);
					result.setDefaultModel("edate", edate);
					result.setDefaultModel("list", list);
					result.setDefaultModel("type", type);
				}
				return result;
			}
		});
		return new ModelAndView("other/consultant_client_reserve_list", modelMap);
	}

	// 异步获取预约查询数据
	@RequestMapping(value = "/consultant_client_reserve_list")
	public ModelAndView consultant_client_reserve_list(ModelMap modelMap, final BaseVo vo,
			final HttpServletRequest request, HttpServletResponse response) throws BaseException {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String sdate = request.getParameter("sdate");
				String edate = request.getParameter("edate");
				String type = request.getParameter("type");

				TgReserve reserve = new TgReserve();

				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
				try {
					if (type.equals("1")) {
						if (sdate != null && !"".equals(sdate)) {
							reserve.setStart(sdf.parse(sdate).getTime() / 1000);
						}
						if (edate != null && !"".equals(edate)) {
							reserve.setDatec(sdf.parse(edate).getTime() / 1000);
						}
					} else if (type.equals("2")) {
						if (sdate != null && !"".equals(sdate)) {
							reserve.setSdate(sdf.parse(sdate));
						}
						if (edate != null && !"".equals(edate)) {
							reserve.setEdate(sdf.parse(edate));
						}
					}
				} catch (ParseException e) {
					e.printStackTrace();
				}

				TgClient client = new TgClient();
				TgUserinfo userinfo = new TgUserinfo();
				TgStudent stu1 = new TgStudent();
				JsonValidator json = new JsonValidator();
				Gson gson = new Gson();

				List<TgReserve> list = reserveDao.getReserve(reserve);
				if (list != null && list.size() > 0) {
					for (TgReserve res : list) {

						if (res.getCdate() != null && !"".equals(res.getCdate())) {
							SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
							String cdate = sdf1.format(new Date(res.getCdate() * 1000));
							res.setStartTime(cdate);
						}

						if (res.getPhone() != null && !"".equals(res.getPhone())) {
							if (res.getPhone().contains("[{")) {
								List<Phone> ph = gson.fromJson(res.getPhone(), new TypeToken<List<Phone>>() {
								}.getType());
								res.setPhlist(ph);
								res.setPhone(res.getPhlist().get(0).getPhone());
							}
						}

						if (res.getRemark() != null && !"".equals(res.getRemark())) {
							res.setRemark(res.getRemark().replace("&nbsp;", "").trim().replace('\"', ' ')
									.replaceAll("</?[^<]+>", ""));
							if (StringUtil.isNum(res.getRemark())) {
								res.setRemark(res.getRemark());
							} else {
								boolean flag = StringUtil.getHanzi(res.getRemark());
								if (!flag) {
									byte[] bytes = StringUtil.hexDecode(res.getRemark());
									String ObjContent;
									try {
										ObjContent = new String(bytes, "UTF-8");
										res.setRemark(ObjContent);
									} catch (UnsupportedEncodingException e) {
										e.printStackTrace();
									}
								} else {
									res.setRemark(res.getRemark().replace("备注:", ""));
								}
							}
						}

						// 学生信息

						client.setKeyname(res.getClient());
						List<TgStudent> stuList = null;
						List<TgClient> cliList = clientDao.findByExample(client);
						if (cliList != null && cliList.size() > 0) {
							stu1.setPkey(cliList.get(0).getKeyname());
							stuList = studentDao.findByExample(stu1);

							String student = res.getRestudent();
							if (student != null && !"".equals(student)) {
								try {
									Boolean flag = json.validate(student);
									String ObjContent = "";
									if (flag) {
										ObjContent = student;
									} else {
										byte[] bytes = StringUtil.hexDecode(student);
										ObjContent = new String(bytes, "UTF-8");
									}
									if (ObjContent.contains("key")) {
										JSONObject obj = JSONObject.fromObject(ObjContent);
										List<StuMsg> smlist = new ArrayList<StuMsg>();
										if (stuList != null && stuList.size() > 0) {
											for (TgStudent s : stuList) {
												JSONObject obj2 = null;
												if (ObjContent.contains("\"key\":\"" + s.getKeyname() + "\"")) {
													obj2 = obj.getJSONObject(s.getKeyname());
												}
												if (obj2 != null) {
													String name = "";
													if (obj2.getString("testuser") != null
															&& !"".equals(obj2.getString("testuser"))) {
														userinfo.setUsername(obj2.getString("testuser"));
														List<TgUserinfo> userlist = userinfoDao.findByExample(userinfo);
														if (userlist != null && userlist.size() > 0) {
															name = userlist.get(0).getNickname();
														}
													}
													StuMsg stuMsg = new StuMsg();
													stuMsg.setKeyname(s.getNickname());
													stuMsg.setMoneylog(obj2.getString("moneylog"));
													stuMsg.setPrice(obj2.getString("price"));
													stuMsg.setType(s.getType());
													stuMsg.setCard(s.getCard());
													stuMsg.setDeadline(s.getDeadline());
													stuMsg.setLesson(s.getLesson());
													stuMsg.setSerial(s.getSerial());
													stuMsg.setTestuser(name);
													smlist.add(stuMsg);
												}
												res.setSmlist(smlist);
											}
										}
									}
								} catch (Exception e) {
									e.printStackTrace();
								}
							}
						}

					}
				}

				// 下载到exl
				String name = WriterExcel.writeExcelReserveByTime(list, type);

				result.setDefaultModel("sdate", sdate);
				result.setDefaultModel("edate", edate);
				result.setDefaultModel("list", list);
				result.setDefaultModel("type", type);
				result.setDefaultModel("name", name);

				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 接待和测评
	@RequestMapping(value = "/receptionXz")
	public ModelAndView receptionXz(ModelMap modelMap, final LoginVo loginVo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, loginVo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String sdate = request.getParameter("sdate");
				String edate = request.getParameter("edate");
				String type = request.getParameter("type");

				TgReception reception = new TgReception();
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
				if (type != null && !"".equals(type)) {
					try {
						if (type.equals("1")) {
							if (sdate != null && !"".equals(sdate)) {
								reception.setDate(sdf.parse(sdate).getTime() / 1000);
							}
							if (edate != null && !"".equals(edate)) {
								reception.setEndTime(sdf.parse(edate).getTime() / 1000);
							}
						}
					} catch (ParseException e) {
						e.printStackTrace();
					}

					TgStudent stu1 = new TgStudent();
					TgClient client = new TgClient();
					JsonValidator json = new JsonValidator();
					Gson gson = new Gson();// new一个Gson对象

					List<TgReception> list = receptionDao.getReception(reception);
					if (list != null && list.size() > 0) {
						for (TgReception rece : list) {
							// 跟踪条数

							// 日期转换
							if (rece.getDate() != null && !"".equals(rece.getDate())) {
								String gtime = sdf.format(new Date(rece.getDate() * 1000));
								rece.setGtime(gtime);
							}
							// 联系方式
							if (rece.getPhone() != null && !"".equals(rece.getPhone())) {
								if (rece.getPhone().contains("[{")) {
									List<Phone> phone1 = gson.fromJson(rece.getPhone(), new TypeToken<List<Phone>>() {
									}.getType());
									rece.setPhlist(phone1);
								}
							}

							// 学生信息
							client.setKeyname(rece.getClient());
							List<TgStudent> stuList = null;

							List<TgClient> cliList = clientDao.findByExample(client);
							if (cliList != null && cliList.size() > 0) {
								stu1.setPkey(cliList.get(0).getKeyname());
								stuList = studentDao.findByExample(stu1);

								String student = rece.getStudent();
								if (student != null && !"".equals(student)) {
									try {
										Boolean flag = json.validate(student);
										String ObjContent = "";
										if (flag) {
											ObjContent = student;
										} else {
											byte[] bytes = StringUtil.hexDecode(student);
											ObjContent = new String(bytes, "UTF-8");
										}
										if (ObjContent.contains("key")) {
											JSONObject obj = JSONObject.fromObject(ObjContent);
											List<StuMsg> smlist = new ArrayList<StuMsg>();
											if (stuList != null && stuList.size() > 0) {
												for (TgStudent s : stuList) {
													JSONObject obj2 = null;
													if (ObjContent.contains("\"key\":\"" + s.getKeyname() + "\"")) {
														obj2 = obj.getJSONObject(s.getKeyname());
													}
													if (obj2 != null) {
														StuMsg stuMsg = new StuMsg();
														stuMsg.setKeyname(obj2.getString("key"));
														stuMsg.setMoneylog(obj2.getString("moneylog"));
														stuMsg.setPrice(obj2.getString("price"));
														stuMsg.setReason(obj2.getString("reason"));
														stuMsg.setResult(obj2.getString("result"));
														stuMsg.setTestuser(s.getNickname());
														smlist.add(stuMsg);
													}
													rece.setSmlist(smlist);
												}
											}
										}
									} catch (Exception e) {
										e.printStackTrace();
									}
								}
							}
						}
					}
					// 下载到exl
					result.setDefaultModel("sdate", sdate);
					result.setDefaultModel("edate", edate);
					result.setDefaultModel("type", type);
					result.setDefaultModel("reception", reception);
					result.setDefaultModel("list", list);
				}
				return result;
			}
		});
		return new ModelAndView("other/consultant_client_reception_list", modelMap);
	}

	// 写入execl
	@RequestMapping(value = "/consultant_client_reception_list")
	public ModelAndView consultant_client_reception_list(ModelMap modelMap, final BaseVo vo,
			final HttpServletRequest request, HttpServletResponse response) throws BaseException {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String sdate = request.getParameter("sdate");
				String edate = request.getParameter("edate");
				String type = request.getParameter("type");
				String stu = request.getParameter("stu");
				String sedate = sdate + "--" + edate;
				TgReception reception = new TgReception();
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
				if (type != null && !"".equals(type)) {
					try {
						if (type.equals("1")) {
							if (sdate != null && !"".equals(sdate)) {
								reception.setDate(sdf.parse(sdate).getTime() / 1000);
							}
							if (edate != null && !"".equals(edate)) {
								reception.setEndTime(sdf.parse(edate).getTime() / 1000);
							}
						}
					} catch (ParseException e) {
						e.printStackTrace();
					}
					TgClient client = new TgClient();
					TgUserinfo userinfo = new TgUserinfo();
					TgStudent stu1 = new TgStudent();
					JsonValidator json = new JsonValidator();

					List<TgReception> list = receptionDao.getReception(reception);
					if (list != null && list.size() > 0) {
						for (TgReception rece : list) {
							// 日期转换
							if (rece.getDate() != null && !"".equals(rece.getDate())) {
								String gtime = sdf.format(new Date(rece.getDate() * 1000));
								rece.setGtime(gtime);
							}
							// 联系方式
							if (rece.getPhone() != null && !"".equals(rece.getPhone())) {
								Gson gson = new Gson();
								if (rece.getPhone().contains("[{")) {
									List<Phone> ph = gson.fromJson(rece.getPhone(), new TypeToken<List<Phone>>() {
									}.getType());
									rece.setPhlist(ph);
									rece.setPhone(rece.getPhlist().get(0).getPhone());
								}
							}

							// 学生信息

							client.setKeyname(rece.getClient());
							List<TgStudent> stuList = null;
							List<TgClient> cliList = clientDao.findByExample(client);
							if (cliList != null && cliList.size() > 0) {
								stu1.setPkey(cliList.get(0).getKeyname());
								stuList = studentDao.findByExample(stu1);
								String student = rece.getStudent();
								if (student != null && !"".equals(student)) {
									try {
										Boolean flag = json.validate(student);
										String ObjContent = "";
										if (flag) {
											ObjContent = student;
										} else {
											byte[] bytes = StringUtil.hexDecode(student);
											ObjContent = new String(bytes, "UTF-8");
										}
										if (ObjContent.contains("key")) {
											JSONObject obj = JSONObject.fromObject(ObjContent);
											List<StuMsg> smlist = new ArrayList<StuMsg>();
											if (stuList != null && stuList.size() > 0) {
												for (TgStudent s : stuList) {
													JSONObject obj2 = null;
													if (ObjContent.contains("\"key\":\"" + s.getKeyname() + "\"")) {
														obj2 = obj.getJSONObject(s.getKeyname());
													}
													if (obj2 != null) {
														String name = "";
														if (obj2.getString("testuser") != null
																&& !"".equals(obj2.getString("testuser"))) {
															userinfo.setUsername(obj2.getString("testuser"));
															List<TgUserinfo> listname = userinfoDao
																	.findByExample(userinfo);
															if (listname.size() > 0) {
																if (listname.get(0).getNickname() != null
																		&& listname.get(0).getNickname() != "") {
																	name = listname.get(0).getNickname();
																}
															}
														}
														StuMsg stuMsg = new StuMsg();
														stuMsg.setKeyname(s.getNickname());
														stuMsg.setMoneylog(obj2.getString("moneylog"));
														stuMsg.setPrice(obj2.getString("price"));
														stuMsg.setType(s.getType());
														stuMsg.setCard(s.getCard());
														stuMsg.setDeadline(s.getDeadline());
														stuMsg.setLesson(s.getLesson());
														stuMsg.setSerial(s.getSerial());
														stuMsg.setResult(obj2.getString("result"));
														stuMsg.setTestuser(name);
														smlist.add(stuMsg);
													}
													rece.setSmlist(smlist);
												}
											}
										}
									} catch (Exception e) {
										e.printStackTrace();
									}
								}
							}
						}
					}

					// 导入excel
					String name = "";
					if (stu != null && stu.equals("1")) {
						name = WriterExcel.writeExcelStudentByTime(list, type, sedate);
					} else {
						name = WriterExcel.writeExcelReceptionByTime(list, type, sedate);
					}
					// 下载Excel
					/**
					 * 连接服务器
					 */
					/**SFTPUtil.getConnection();
					try {
						System.out.println("文件名：" + name);
						SFTPUtil.download(Constants.FOLDER_EXCEL, name, "d://" + name);
					} catch (FileNotFoundException | SftpException e) {
						e.printStackTrace();
					}
					result.setDefaultModel("sdate", sdate);
					result.setDefaultModel("edate", edate);
					result.setDefaultModel("type", type);
					result.setDefaultModel("name", name);
					result.setDefaultModel("reception", reception);
					result.setDefaultModel("list", list);
					 */
					result.setDefaultModel("name", name);
					result.setDefaultModel("type", type);
				}
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 进入异步下载页面
	@RequestMapping(value = "/clientlistXz")
	public ModelAndView client_list(ModelMap modelMap, final LoginVo loginVo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, loginVo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String sdate = request.getParameter("sdate");
				String edate = request.getParameter("edate");
				String type = request.getParameter("type");

				TgClient client = new TgClient();
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
				if (type != null && !"".equals(type)) {
					try {
						if (type.equals("1")) {
							if (sdate != null && !"".equals(sdate)) {
								client.setStartTime(sdf.parse(sdate).getTime() / 1000);
							}
							if (edate != null && !"".equals(edate)) {
								client.setEndTime((sdf.parse(edate).getTime() / 1000) + 86400);
							}
						}
					} catch (ParseException e) {
						e.printStackTrace();
					}

					List<TgClient> list = clientDao.clientlistXz(client);
					TgStudent student = new TgStudent();
					if (list != null && list.size() > 0) {
						for (TgClient res : list) {
							if (res.getCdate() != null && !"".equals(res.getCdate())) {
								SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
								String cdate = sdf1.format(new Date(res.getCdate() * 1000));
								res.setDateTime(cdate);
							}

							if (res.getPhone() != null && !"".equals(res.getPhone())) {
								Gson gson = new Gson();// new一个Gson对象
								if (res.getPhone().contains("[{")) {
									List<Phone> phone = gson.fromJson(res.getPhone(), new TypeToken<List<Phone>>() {
									}.getType());
									res.setPhlist(phone);
								}
							}
							// 学生
							/*
							 * if (res.getKeyname() != null && !"".equals(res.getKeyname())) {
							 * student.setPkey(res.getKeyname()); List<TgStudent> studentList =
							 * studentDao.getAgeFeature(student); if (studentList != null &&
							 * studentList.size() > 0) { String stu = ""; for (int i = 0; i <
							 * studentList.size(); i++) { Integer age = studentList.get(i).getAge(); if(age
							 * == null){ age =0; } stu += studentList.get(i).getNickname() +
							 * "<span class=\"caption\">(" + age+"岁" + ")</span>,"; } res.setStudent(stu); }
							 * }
							 */

						}
					}
					// 下载到exl
					result.setDefaultModel("sdate", sdate);
					result.setDefaultModel("edate", edate);
					result.setDefaultModel("list", list);
					result.setDefaultModel("type", type);
				}
				return result;
			}
		});
		return new ModelAndView("other/consultant_client_list", modelMap);
	}

	// 下载并写入execl
	@RequestMapping(value = "/consultant_client_list")
	public ModelAndView consultant_client_list(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			HttpServletResponse response) throws BaseException {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String sdate = request.getParameter("sdate");
				String edate = request.getParameter("edate");
				String type = request.getParameter("type");
				TgClient client = new TgClient();
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
				if (type != null && !"".equals(type)) {
					try {
						if (type.equals("1")) {
							if (sdate != null && !"".equals(sdate)) {
								client.setStartTime(sdf.parse(sdate).getTime() / 1000);
							}
							if (edate != null && !"".equals(edate)) {
								client.setEndTime((sdf.parse(edate).getTime() / 1000) + 86400);
							}
						}
					} catch (ParseException e) {
						e.printStackTrace();
					}

					List<TgClient> clist = clientDao.clientlistXz(client);
					TgStudent student = new TgStudent();
					Gson gson = new Gson();
					if (clist != null && clist.size() > 0) {
						for (TgClient res : clist) {
							if (res.getCdate() != null && !"".equals(res.getCdate())) {
								SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
								String cdate = sdf1.format(new Date(res.getCdate() * 1000));
								res.setDateTime(cdate);
							}
							if (res.getPhone() != null && !"".equals(res.getPhone())) {
								// new一个Gson对象
								if (res.getPhone().contains("[{")) {
									List<Phone> phone = gson.fromJson(res.getPhone(), new TypeToken<List<Phone>>() {
									}.getType());
									res.setPhlist(phone);
									if (res.getPhlist().get(0).getPhone() != null
											&& res.getPhlist().get(0).getPhone() != "") {
										res.setPhone(res.getPhlist().get(0).getPhone());
									}
								}
							}
							// 学生
							if (res.getKeyname() != null && !"".equals(res.getKeyname())) {
								student.setPkey(res.getKeyname());
								List<TgStudent> studentList = studentDao.getAgeFeature(student);
								if (studentList != null && studentList.size() > 0) {
									String stu = "";
									for (int i = 0; i < studentList.size(); i++) {
										String age = studentList.get(i).getAge();
										if (age == null) {
											age = "0";
										}
										stu += studentList.get(i).getNickname() + "(" + age + "岁" + "),";
									}
									res.setStudent(stu);
								}
							}
						}
					}
					// 下载到exl
					String name = WriterExcel.writeExcelClientByTime(clist, type, sdate, edate);

					result.setDefaultModel("sdate", sdate);
					result.setDefaultModel("edate", edate);
					result.setDefaultModel("name", name);
					result.setDefaultModel("list", clist);
					result.setDefaultModel("type", type);
				}
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 接待周统计导出
	@RequestMapping(value = "/exportAjaxExcel")
	public String ajaxUploadExcel(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String stat = request.getParameter("startTime");
		String end = request.getParameter("endTime");
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		TgUserinfo user = new TgUserinfo();
		user.setJob("课程顾问");
		if (stat == null || "".equals(stat)) {
			Calendar date = Calendar.getInstance();
			date.setTime(new Date());
			date.set(Calendar.DATE, date.get(Calendar.DATE) - 7);
			Date endDate = null;
			try {
				endDate = sdf.parse(sdf.format(date.getTime()));
			} catch (ParseException e) {
				e.printStackTrace();
			}

			List<String> timelist = DateUtil.printWeekdays(sdf.format(endDate));
			stat = timelist.get(0);
			end = timelist.get(timelist.size() - 1);
		}

		Integer total = userinfoDao.getUsernameCont(user);
		Page page = PageUtil.createPage(total, 1, total);
		List<TgUserinfo> list = userinfoDao.getUserInfoUsername(user, page);
		float mary_sum = 0;
		int mary_zon = 0;
		int mary_fei = 0;
		int mary_zonear = 0;
		float mary_sum1 = 0;
		int mary_zonshichang = 0;

		DecimalFormat fnum = new DecimalFormat("#.##%");
		DecimalFormat fnu = new DecimalFormat("#.##");

		if (list != null && list.size() > 0) {
			try {
				TgReception rece = new TgReception();
				TgReception rece1 = new TgReception();
				for (TgUserinfo use : list) {
					rece.setUsername(use.getUsername());
					rece.setStartTime(sdf.parse(stat).getTime() / 1000);
					rece.setEndTime(sdf.parse(end).getTime() / 1000);

					rece1.setUsername(use.getUsername());
					rece1.setStartTime(sdf.parse(stat).getTime() / 1000);
					rece1.setEndTime(sdf.parse(end).getTime() / 1000);
					rece1.setC_keyname("市场部推广，传单派发，公益讲座");

					List<TgReception> reslist = receptionDao.getMoneyEar(rece);
					List<TgReception> ear = receptionDao.getEarnest(rece);
					List<TgReception> earlist = receptionDao.getEarnest1(rece);

					List<TgReception> reslist1 = receptionDao.getMoneyEar(rece1);
					List<TgReception> ear1 = receptionDao.getEarnest(rece1);
					List<TgReception> earlist1 = receptionDao.getEarnest1(rece1);

					// 总的接待量
					Integer zonRece = receptionService.getZonlReceptionCount(rece);
					// 市场的接待量
					Integer zonear = receptionDao.getZonlEarnestCount(rece1);
					// 总业绩
					float sum = (float) 0;
					int zondan = 0;
					if (ear != null && !"".equals(ear)) {
						for (int i = 0; i < ear.size(); i++) {
							if (ear.get(i).getEarnest_date() != null) {
								if (sdf.parse(stat).getTime() / 1000 <= ear.get(i).getEarnest_date()
										&& ear.get(i).getEarnest_date() <= sdf.parse(end).getTime() / 1000) {
									if (ear.get(i).getMoney() != null) {
										sum += ear.get(i).getMoney();
									} else if (ear.get(i).getEarnest() != null) {
										sum += ear.get(i).getEarnest();
									}
									zondan += 1;
								} else if (ear.get(i).getMoney() != null && ear.get(i).getEarnest() != null) {
									sum += ear.get(i).getMoney() - ear.get(i).getEarnest();
								}
							} else if (ear.get(i).getEarnest_date() == null && ear.get(i).getMoney() != null) {
								sum += ear.get(i).getMoney();
								zondan += 1;
							}

						}
					}
					if (reslist != null && !"".equals(reslist)) {
						for (int i = 0; i < reslist.size(); i++) {
							if (reslist.get(i).getMoney1() != null) {
								sum += reslist.get(i).getMoney1();
							}
						}
					}
					if (earlist != null && !"".equals(earlist)) {
						for (int i = 0; i < earlist.size(); i++) {
							if (earlist.get(i).getRep_date() == null) {
								if (earlist.get(i).getEarnest() != null) {
									sum += earlist.get(i).getEarnest();
									zondan += 1;
								}
							} else if (sdf.parse(end).getTime() / 1000 <= earlist.get(i).getRep_date()) {
								sum += earlist.get(i).getEarnest();
								zondan += 1;
							}
						}
					}
					// 市场业绩
					float sum1 = (float) 0;
					int zonshichang = 0;
					if (ear1 != null && !"".equals(ear1)) {
						for (int i = 0; i < ear1.size(); i++) {
							if (ear1.get(i).getEarnest_date() != null) {
								if (sdf.parse(stat).getTime() / 1000 <= ear1.get(i).getEarnest_date()
										&& ear1.get(i).getEarnest_date() <= sdf.parse(end).getTime() / 1000) {
									if (ear1.get(i).getMoney() != null) {
										sum1 += ear1.get(i).getMoney();
									} else if (ear.get(i).getEarnest() != null) {
										sum1 += ear1.get(i).getEarnest();
									}
									zonshichang += 1;
								} else if (ear1.get(i).getMoney() != null && ear1.get(i).getEarnest() != null) {
									sum1 += ear1.get(i).getMoney() - ear1.get(i).getEarnest();
								}
							} else if (ear1.get(i).getEarnest_date() == null && ear1.get(i).getMoney() != null) {
								sum1 += ear1.get(i).getMoney();
								zonshichang += 1;
							}
						}
					}
					if (reslist1 != null && !"".equals(reslist1)) {
						for (int i = 0; i < reslist1.size(); i++) {
							if (reslist1.get(i).getMoney1() != null) {
								sum1 += reslist1.get(i).getMoney1();
							}
						}
					}
					if (earlist1 != null && !"".equals(earlist1)) {
						for (int i = 0; i < earlist1.size(); i++) {
							if (earlist1.get(i).getRep_date() == null) {
								if (earlist1.get(i).getEarnest() != null) {
									sum += earlist1.get(i).getEarnest();
									zonshichang += 1;
								}
							} else if (sdf.parse(end).getTime() / 1000 <= earlist1.get(i).getRep_date()) {
								sum += earlist1.get(i).getEarnest();
								zonshichang += 1;
							}
						}
					}
					// 非市场业绩
					float sum3 = sum - sum1;
					// 非市场的接待量
					int zon = zonRece - zonear;
					// 非市场的成单
					int fei = zondan - zonshichang;
					mary_sum = mary_sum + sum3;
					mary_zon = mary_zon + zon;
					mary_fei = mary_fei + fei;
					mary_zonear = mary_zonear + zonear;
					mary_sum1 = mary_sum1 + sum1;
					mary_zonshichang = mary_zonshichang + zonshichang;

					use.setFeisum(String.valueOf(sum3));
					use.setShisum(String.valueOf(sum1));
					use.setZonrece(zon);
					use.setZonear(zonear);
					use.setFeizon(fei);
					use.setZonchen(zonshichang);

					if (zon != 0 && fei != 0) {
						float rese = (float) fei / zon;
						String feichenrate = fnum.format(rese);
						use.setFeichenrate(feichenrate);
						use.setRates(Double.valueOf(rese));

					} else {
						String che = "0";
						use.setFeichenrate(che);
						use.setRates(Double.valueOf(che));

					}

					if (zonear != 0 && zonshichang != 0) {
						float rese = (float) zonshichang / zonear;
						String chenrate = fnum.format(rese);
						use.setChenrate(chenrate);
					} else {
						String che = "0";
						use.setChenrate(che);
					}

					if (sum3 != 0 && zon != 0) {
						float rese = (float) sum3 / zon;
						String sumrate = fnu.format(rese);
						use.setSumrate(sumrate);
					} else {
						String che = "0";
						use.setSumrate(che);
					}
				}

				// 创建HSSFWorkbook对象(excel的文档对象)
				HSSFWorkbook wb = new HSSFWorkbook();
				// 建立新的sheet对象（excel的表单）
				HSSFSheet sheet = wb.createSheet("咨询业绩周统计");
				// 在sheet里创建第一行，参数为行索引(excel的行)，可以是0～65535之间的任何一个
				HSSFRow row1 = sheet.createRow(0);
				row1.setHeight((short) 500);
				HSSFCellStyle style = wb.createCellStyle();
				style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
				HSSFFont font = wb.createFont();
				style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
				style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
				font.setFontName("微软雅黑");
				font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); // 字体增粗
				font.setFontHeightInPoints((short) 18);// 设置字体大小
				style.setFont(font);
				// 创建单元格（excel的单元格，参数为列索引，可以是0～255之间的任何一个
				HSSFCell cell = row1.createCell(0);
				cell.setCellStyle(style);
				// 设置单元格内容
				cell.setCellValue(stat + "-" + end);
				// 合并单元格CellRangeAddress构造参数依次表示起始行，截至行，起始列， 截至列
				sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 11));
				sheet.setColumnWidth(0, 25 * 256);
				CellStyle style2 = wb.createCellStyle();
				style2.setAlignment(HSSFCellStyle.ALIGN_CENTER);
				HSSFFont font2 = wb.createFont();
				style2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
				style2.setAlignment(HSSFCellStyle.ALIGN_CENTER);
				font2.setFontName("微软雅黑");
				font2.setFontHeightInPoints((short) 12);// 设置字体大小
				style2.setFont(font2);
				style2.setWrapText(true);// 设置自动换行
				// 在sheet里创建第二行
				HSSFRow row2 = sheet.createRow(1);
				row2.setHeightInPoints(50);
				// 创建单元格并设置单元格内容
				row2.createCell(0).setCellValue("校区");
				row2.createCell(1).setCellValue("课程顾问");
				row2.createCell(2).setCellValue("带教老师");
				row2.createCell(3).setCellValue("当周新增业绩");
				row2.createCell(4).setCellValue("当周接待测评量");
				row2.createCell(5).setCellValue("当周成单家庭数");
				row2.createCell(6).setCellValue("当周成单率");
				row2.createCell(7).setCellValue("当周业绩/接待测评量");
				row2.createCell(8).setCellValue("当周市场新增业绩");
				row2.createCell(9).setCellValue("当周市场接待测评量");
				row2.createCell(10).setCellValue("当周市场成单家庭数");
				row2.createCell(11).setCellValue("当周市场成单率");

				for (int i = 0; i < 12; i++) {
					row2.getCell(i).setCellStyle(style2);
				}
				CellStyle style3 = wb.createCellStyle();
				style3.setAlignment(HSSFCellStyle.ALIGN_CENTER);
				HSSFFont font3 = wb.createFont();
				style3.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
				style3.setAlignment(HSSFCellStyle.ALIGN_CENTER);
				style3.setFont(font3);

				MySortList<TgUserinfo> msList = new MySortList<TgUserinfo>();
				msList.sortByMethod(list, "getRates", false);
				// 百分数格式化
				NumberFormat fmt = NumberFormat.getPercentInstance();
				fmt.setMaximumFractionDigits(2);// 最多两位百分小数，如25.23%
				for (int j = 0; j < list.size(); j++) {
					sheet.setColumnWidth(j + 1, 12 * 256);
					HSSFRow row3 = sheet.createRow(2 + j);
					row3.createCell(0).setCellValue(list.get(j).getOff_name());
					row3.createCell(1).setCellValue(list.get(j).getNickname());
					row3.createCell(2).setCellValue(list.get(j).getCon_name());
					row3.createCell(3).setCellValue(list.get(j).getFeisum());
					row3.createCell(4).setCellValue(list.get(j).getZonrece());
					row3.createCell(5).setCellValue(list.get(j).getFeizon());
					row3.createCell(6).setCellValue(fmt.format(list.get(j).getRates()));
					row3.createCell(7).setCellValue(list.get(j).getSumrate());
					row3.createCell(8).setCellValue(list.get(j).getShisum());
					row3.createCell(9).setCellValue(list.get(j).getZonear());
					row3.createCell(10).setCellValue(list.get(j).getZonchen());
					row3.createCell(11).setCellValue(list.get(j).getChenrate());
					for (int i = 0; i < 12; i++) {
						row3.getCell(i).setCellStyle(style3);
					}
				}
				CellStyle style4 = wb.createCellStyle();
				style4.setAlignment(HSSFCellStyle.ALIGN_CENTER);
				HSSFFont font4 = wb.createFont();
				font4.setColor(HSSFColor.RED.index);// HSSFColor.VIOLET.index
													// //字体颜色
				style4.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
				style4.setAlignment(HSSFCellStyle.ALIGN_CENTER);
				style4.setFont(font4);
				style4.setWrapText(true);// 设置自动换行
				HSSFRow row4 = sheet.createRow(2 + list.size());
				row4.createCell(0).setCellValue("汇总");
				row4.createCell(1).setCellValue("");
				row4.createCell(2).setCellValue("");
				row4.createCell(3).setCellValue(mary_sum);
				row4.createCell(4).setCellValue(mary_zon);
				row4.createCell(5).setCellValue(mary_fei);
				row4.createCell(6).setCellValue("");
				row4.createCell(7).setCellValue("");
				row4.createCell(8).setCellValue(mary_sum1);
				row4.createCell(9).setCellValue(mary_zonear);
				row4.createCell(10).setCellValue(mary_zonshichang);
				row4.createCell(11).setCellValue("");

				for (int i = 0; i < 12; i++) {
					row4.getCell(i).setCellStyle(style4);
				}
				// 输出Excel文件
				OutputStream output = response.getOutputStream();
				response.reset();
				response.setHeader("Content-disposition",
						"attachment;filename=" + URLEncoder.encode("咨询业绩周统计.xls", "UTF-8"));
				response.setContentType("application/msexcel;charset=UTF-8");
				wb.write(output);
				output.close();

			} catch (Exception e) {
				response.setContentType("text/html;charset=UTF-8");
				response.setCharacterEncoding("UTF-8");
				response.setHeader("Cache-Control", "no-cache");
				PrintWriter out = response.getWriter();
				out.println("<script language='javascript'>");
				out.println("alert('导出失败!')");
				out.println("history.go(-1)");
				out.println("</script>");
				out.flush();
				out.close();
				out = null;
				return null;
			}
		}
		return null;
	}

	// 缴费列表
	@RequestMapping(value = "/moneyList")
	public ModelAndView moneyList(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String center = request.getParameter("center");
				String stu_name = request.getParameter("stu_name");
				String state = request.getParameter("state");
				String nickname1 = request.getParameter("nickname1");

				TgMoney money = new TgMoney();

				if (center != null && !"".equals(center) && !Constants.SPECIAL_CENTER.equals(center)) {
					money.setCenter(center);
				}
				if (stu_name != null && !"".equals(stu_name)) {
					money.setStu_name(stu_name);
				}
				if (state != null && !"".equals(state)) {
					money.setState(Integer.valueOf(state));
				}
				if (nickname1 != null && !"".equals(nickname1)) {
					money.setNickname1(nickname1);
				}

				Integer currPage = 1;
				if (vo.getCurrPage() != null && !"".equals(vo.getCurrPage())) {
					currPage = vo.getCurrPage();
				}
				Integer total = 0;
				List<TgMoney> list = null;
				Page page = null;
				if (Constants.SPECIAL_CENTER.equals(center)) {// 是特殊老师权限的
					total = moneyDao.getMonCountByType_two(money);
					page = PageUtil.createPage(8, currPage, total);
					list = moneyDao.getMoneysByType_two(money, page);
				} else {
					total = moneyDao.getMonCountByType(money);
					page = PageUtil.createPage(8, currPage, total);
					list = moneyDao.getMoneysByType(money, page);
				}

				if (list != null) {
					Gson gson = new Gson();
					for (TgMoney m : list) {
						// 联系方式
						if (m.getPhone() != null && !"".equals(m.getPhone())) {
							if (m.getPhone().contains("[{")) {
								List<Phone> phone1 = gson.fromJson(m.getPhone(), new TypeToken<List<Phone>>() {
								}.getType());
								m.setPhlist(phone1);
							}
						}
					}

				}

				result.setDefaultModel("money", money);
				result.setDefaultModel("list", list);
				result.setDefaultModel("page", page);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 缴费详情
	@RequestMapping(value = "/updt")
	public ModelAndView updt(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				// 添加参数
				String type = request.getParameter("type");
				String nickname = request.getParameter("nickname");
				String job = request.getParameter("job");
				String region = request.getParameter("region");
				String usergroup = request.getParameter("usergroup");
				String qq_group_id = request.getParameter("qq_group_id");
				String entryday = request.getParameter("entryday");
				String zhuanz_date = request.getParameter("zhuanz_date");
				String username = request.getParameter("username");
				String password = request.getParameter("password");
				String locked = request.getParameter("locked");

				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

				TgUser user = new TgUser();
				user.setUsername(username);
				List<TgUser> list = userDao.findByExample(user);
				if (list != null && list.size() > 0) {
					if (usergroup != null && !"".equals(usergroup)) {
						user.setUsergroup(Integer.parseInt(usergroup));
					}
					user.setId(list.get(0).getId());
					if (!password.equals("") && password != null) {
						String salt = "HKUUKOIIKJKLLI";
						user.setPassword(MD5.md5(password + salt));
					}
					/*
					 * if(dbPasswordMd5!=null && !"".equals(dbPasswordMd5)){
					 * 
					 * }
					 */
					if (locked != null && !"".equals(locked)) {
						user.setLocked(Integer.parseInt(locked));
					}
					userDao.update(user);

					TgUserinfo userInfo = new TgUserinfo();
					userInfo.setUsername(username);
					List<TgUserinfo> infoList = userinfoDao.findByExample(userInfo);
					userInfo.setId(infoList.get(0).getId());
					if (type != null && !"".equals(type)) {
						userInfo.setType(Integer.valueOf(type));
					} else {
						userInfo.setType(0);
					}
					if (nickname != null && !"".equals(nickname)) {
						userInfo.setNickname(nickname);
					}
					if (region != null && !"".equals(region)) {
						userInfo.setRegion(region);
					}
					if (job != null && !"".equals(job)) {
						userInfo.setDepartment(job);
					}
					if (qq_group_id != null && !"".equals(qq_group_id)) {
						userInfo.setQq_group(Long.valueOf(qq_group_id));
					}
					if (zhuanz_date != null && !"".equals(zhuanz_date)) {
						userInfo.setZhuanz_date(zhuanz_date);
					}
					if (entryday != null && !"".equals(entryday)) {
						try {
							userInfo.setEntryday(sdf.parse(entryday).getTime() / 1000);
						} catch (ParseException e) {
							e.printStackTrace();
						}
					}
					userInfo.setMdate(new Date().getTime() / 1000);
					userinfoDao.update(userInfo);
					result.setDefaultModel("flag", "1");
				}
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 缴费详情
	@RequestMapping(value = "/moenysDetail")
	public ModelAndView addMoenys(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("id");

				TgMoney money = new TgMoney();
				if (id != null && !"".equals(id)) {
					money.setId(Long.valueOf(id));
				}

				Integer currPage = 1;
				if (vo.getCurrPage() != null && !"".equals(vo.getCurrPage())) {
					currPage = vo.getCurrPage();
				}
				Integer total = moneyDao.getMonCountByType(money);
				Page page = PageUtil.createPage(1, currPage, total);
				List<TgMoney> list = moneyDao.getMoneysByType(money, page);
				if (list != null && list.size() > 0) {
					money = list.get(0);
				}
				result.setDefaultModel("money", money);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	/**
	 * @Title: 方法名：money_state
	 * @Description: 功能描述： 缴费审核
	 * @author hqD ☺ ^o^
	 * @date 2017年12月7日 下午2:37:24
	 * @param @param
	 *            modelMap
	 * @param @param
	 *            vo
	 * @param @param
	 *            request
	 * @param @param
	 *            response
	 * @param @return
	 * @param @throws
	 *            BaseException
	 * @return ModelAndView 返回类型
	 */
	@RequestMapping(value = "/money_state")
	public ModelAndView money_state(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			HttpServletResponse response) throws BaseException {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				Result result_false = new ResultSupport(false);
				try {
					String id = request.getParameter("id");
					String state_name = request.getParameter("state_name");
					String state = request.getParameter("state");
					String state_beizhu = request.getParameter("state_beizhu");

					String type = request.getParameter("type");// 老师类型
					String center = request.getParameter("center");// 交款中心（中心主任审核需要这个中心）
					System.out.println(center + "-0000-" + state_name);
					if (id != null && !"".equals(id)) {
						TgMoney money = moneyDao.findById(TgMoney.class, Long.valueOf(id));
						if (state.equals("2")) {
							if (money.getStu_id() != null) {
								TgStudent student = new TgStudent();
								// 中心主任 可以直接审核（这里的 student 就不需要这么查询）
								if ("1".equals(type)) {// 是中心主任审核
									student = studentDao.findById(TgStudent.class, money.getStu_id());
								} else {// 普通老师审核
									student = studentDao.getStudentById(money.getStu_id());
									center = student.getCenter();
									if (MathUtil.isNotEmpty(center)) {
										if (student.getCenter().equals("成都桐梓(zǐ)林中心")) {
											center = "成都桐梓林中心";
										} else if (center.equals("广州区(ōu)庄中心")) {
											center = "广州区庄中心";
										}
									} else {
										System.out.println("请添加学员接待信息");
										return result_false;
									}

								}
								String name = "";
								if (student == null) {
									TgStudent stu = new TgStudent();
									stu.setNickname(money.getStu_name());
									List<TgStudent> list = studentDao.findByExample(stu);
									if (list != null && list.size() == 1) {
										student = list.get(0);
										name = list.get(0).getNickname();
										if (name != null && !"".equals(name) && !"null".equals(name)) {
											name = URLEncoder.encode(name, "utf-8");
										} else {
											name = "";
										}
									}
								} else {
									name = student.getNickname();
									if (name != null && !"".equals(name) && !"null".equals(name)) {
										name = URLEncoder.encode(student.getNickname(), "utf-8");
									} else {
										name = "";
									}
								}
								center = URLEncoder.encode(center, "utf-8");

								String is_taiyou = "0";
								if (student.getPra_type() != null && student.getPra_type() == 4) {
									is_taiyou = "1";
								}

								String situation = "";
								if (student.getPra_type() != null) {
									String s_pra = "";
									if (student.getS_pra() == null || "".equals(student.getS_pra())) {
										s_pra = "无";
									} else {
										s_pra = student.getS_pra();
									}
									if (student.getPra_type() == 1) {
										situation = "非脑电" + student.getTimes() + "次，赠送课时：" + s_pra;
									} else if (student.getPra_type() == 2) {
										situation = "普通中心" + student.getTimes() + "次，赠送课时：" + s_pra;
									} else if (student.getPra_type() == 3) {
										situation = "全脑" + student.getTimes() + "次，赠送课时：" + s_pra;
									} else if (student.getPra_type() == 4) {
										situation = "太优" + student.getTimes() + "次，赠送课时：" + s_pra;
									} else if (student.getPra_type() == 5) {
										situation = "家庭训练" + student.getTimes() + "月，赠送课时：" + s_pra;
									} else if (student.getPra_type() == 6) {
										situation = "夏令营";
									} else if (student.getPra_type() == 7) {
										situation = "上门费，赠送课时：" + s_pra;
									} else if (student.getPra_type() == 8) {
										situation = "暑期培优班(新)" + student.getTimes() + "次，赠送课时：" + s_pra;
									} else if (student.getPra_type() == 9) {
										situation = "暑期培优班(旧)，赠送课时：" + s_pra;
									}
								}
								if (situation != null && !"".equals(situation)) {
									situation = URLEncoder.encode(situation, "utf-8");
								}
								String url = "http://www.yueqiao.org/web/teaweb/addStudent.json?id=" + student.getId()
										+ "&name=" + name + "&center=" + center + "&is_taiyou=" + is_taiyou
										+ "&situation=" + situation;
								String teacher = HttpUtil.doGet(url, "", "utf-8", true);
								JSONObject obj = JSONObject.fromObject(teacher);
								String msg = obj.getString("msg");
								if (msg != null && msg.equals("1")) {
									money.setState(Integer.valueOf(state));
									money.setIsSuccess(Integer.valueOf(0));
									money.setState_name(state_name);
									money.setState_beizhu(state_beizhu);
									moneyDao.update(money);
									result.setDefaultModel("msg", "1");
								}
							} else {
								money.setState(Integer.valueOf(state));
								money.setIsSuccess(Integer.valueOf(0));
								money.setState_name(state_name);
								money.setState_beizhu(state_beizhu);
								moneyDao.update(money);
								result.setDefaultModel("msg", "1");
							}
						} else {
							money.setState(Integer.valueOf(state));
							money.setState_name(state_name);
							money.setState_beizhu(state_beizhu);
							moneyDao.update(money);
							result.setDefaultModel("msg", "1");
						}
					} else {
						result.setDefaultModel("msg", "0");
					}
				} catch (UnsupportedEncodingException e) {
					e.printStackTrace();
				}
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// POS机列表
	@RequestMapping(value = "/posList")
	public ModelAndView posList(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String center = request.getParameter("center");

				TgPos pos = new TgPos();
				if (center != null && !"".equals(center)) {
					pos.setCenter(center);
				}

				Integer currPage = 1;
				if (vo.getCurrPage() != null && !"".equals(vo.getCurrPage())) {
					currPage = vo.getCurrPage();
				}
				Integer total = posDao.getPosCountByType(pos);
				Page page = PageUtil.createPage(8, currPage, total);
				List<TgPos> list = posDao.getPosListByType(pos, page);

				TgOffice office = new TgOffice();
				List<TgOffice> offList = tgOfficeDao.getOfficeName(office);

				result.setDefaultModel("offList", offList);
				result.setDefaultModel("pos", pos);
				result.setDefaultModel("list", list);
				result.setDefaultModel("page", page);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	@RequestMapping(value = "/addpos")
	public ModelAndView addpos(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);

				String id = request.getParameter("id");
				if (id != null && !"".equals(id)) {
					TgPos pos = new TgPos();
					pos.setId(Long.valueOf(id));

					Integer currPage = 1;
					if (vo.getCurrPage() != null && !"".equals(vo.getCurrPage())) {
						currPage = vo.getCurrPage();
					}
					Integer total = posDao.getPosCountByType(pos);
					Page page = PageUtil.createPage(1, currPage, total);
					List<TgPos> list = posDao.getPosListByType(pos, page);
					if (list != null && list.size() > 0) {
						pos = list.get(0);
						result.setDefaultModel("pos", pos);
					}
				}

				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	/* start-------------------------------采购管理------------------------ */
	// 物品列表
	@RequestMapping(value = "/goodsList")
	public ModelAndView posList(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String goodsId = request.getParameter("good_name_id");
				String center_name = request.getParameter("center_name");
				if (goodsId == null||goodsId.equals("null")) {
					goodsId = null;
				}
				if (center_name == null||center_name.equals("null")) {
					center_name = null;
				}
				TgGoods goods = new TgGoods();
				TgGoodsKey tgGoodKey = null;
				if (goodsId == null || "".equals(goodsId) || Long.valueOf(goodsId) == 1) {
					goods.setGood_name_id(1l);
					goods.setField("center_name,model,code,purpose,state,msg");
				} else if (Long.valueOf(goodsId) == 2) {
					goods.setGood_name_id(2l);
					goods.setField("item_name,use_period,postage,residual_length,msg"); // 404电话
				} else if (Long.valueOf(goodsId) == 3) {
					goods.setGood_name_id(3l);
					goods.setField("center_name,msg,renew_time,postage,supplier,broadband_type,broadband_type2"); // 宽带
				} else if (Long.valueOf(goodsId) == 4) {
					goods.setGood_name_id(4l);
					goods.setField("item_name,number,msg,unit_price,purchasing_link");// 办公家具
				} else if (Long.valueOf(goodsId) == 5) {
					goods.setGood_name_id(5l);
					goods.setField("item_name,model,code,purchasing_link"); // 流量卡
				} else if (Long.valueOf(goodsId) == 6) {
					goods.setGood_name_id(6l);
					goods.setField("item_name,number,unit_price,msg"); // 办公相关
				} else if (Long.valueOf(goodsId) == 7) {
					goods.setGood_name_id(7l);
					goods.setField("item_name,number,unit_price,msg"); // 伯温文具+玩具
				} else if (Long.valueOf(goodsId) == 8) {
					goods.setGood_name_id(8l);
					goods.setField("item_name,number,company,center_name,msg"); // 学院路寄送物品
				} else if (Long.valueOf(goodsId) == 9) {
					goods.setGood_name_id(9l);
					goods.setField("item_name,number,unit_price,purchasing_link"); // 训练用品
				} else if (Long.valueOf(goodsId) == 10) {
					goods.setGood_name_id(10l);
					goods.setField("item_name,number,purchasing_link"); // 书籍
				} else if (Long.valueOf(goodsId) == 11) {
					goods.setGood_name_id(11l);
					goods.setField("item_name,msg,number,purchasing_link"); // 灯具
				} else if (Long.valueOf(goodsId) == 12) {
					goods.setGood_name_id(12l);
					goods.setField("item_name,number");// 消耗品
				} else if (Long.valueOf(goodsId) == 13) { // 钥匙
					tgGoodKey = new TgGoodsKey();
					if (center_name != null && !center_name.equals("全部")) {
						tgGoodKey.setCenter_name(center_name);
					}
				} else if (Long.valueOf(goodsId) == 14) {
					goods.setGood_name_id(14l);
					goods.setField("center_name,model,code,phone,responsible_tea");// 手机资费情况
				} else if (Long.valueOf(goodsId) == 15) {
					goods.setGood_name_id(15l);
					goods.setField("center_name,number,state");// 手机资费情况
				}
				Integer currPage = 1;
				if (vo.getCurrPage() != null && !"".equals(vo.getCurrPage())) {
					currPage = vo.getCurrPage();
				}
				Integer total;
				Page page;
				if (goodsId != null && !"".equals(goodsId) && Long.valueOf(goodsId) == 13) {
					total = tgGoodKeyDao.getGoodsKeyCountInfo(tgGoodKey);
					page = PageUtil.createPage(8, currPage, total);
					List<TgGoodsKey> list = tgGoodKeyDao.getGoodsKeyInfo(tgGoodKey, page);
					result.setDefaultModel("list", list);
					result.setDefaultModel("good_name_id", 13);
					result.setDefaultModel("center_name", center_name);
				} else {
					total = goodsDao.getGoodsCountByType(goods);
					page = PageUtil.createPage(8, currPage, total);
					List<TgGoods> list = goodsDao.getGoodsByType(goods, page);
					result.setDefaultModel("list", list);
					result.setDefaultModel("good_name_id", list.get(0).getGood_name_id());
				}
				TgOffice office = new TgOffice();
				List<TgOffice> offList = tgOfficeDao.getOfficeName(office);
				TgGoodsAccount tgGoodsAccount = new TgGoodsAccount();
				tgGoodsAccount.setApply_status(4);
				tgGoodsAccount.setApplied(1);
				Integer total2 = tgGoodsAccountDao.getGoodsAccountCountInfo(tgGoodsAccount);
				TgGoodsAccount tgGoodsAccount2 = new TgGoodsAccount();
				tgGoodsAccount2.setApply_status(4);
				tgGoodsAccount2.setApplied(2);
				Integer total3 = tgGoodsAccountDao.getGoodsAccountCountInfo(tgGoodsAccount2);
				result.setDefaultModel("offList", offList);
				result.setDefaultModel("page", page);
				result.setDefaultModel("total2", total2);
				result.setDefaultModel("total3", total3);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}
	// 物品列表
	@RequestMapping(value = "/goodsTypeList")
	public ModelAndView goodsTypeList(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				GoodsMnus gm = new GoodsMnus();
                gm.setParint_id(0);
                List<GoodsMnus> list = goodsMnusDao.getGoodsmnus(gm);
				result.setDefaultModel("list", list);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	/* end-------------------------------采购管理------------------------ */

	/* start-------------------------------中心打分------------------------ */
	@RequestMapping(value = "/markList")
	public ModelAndView salesExecutive(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String add_username = request.getParameter("add_username");
				String nickname = request.getParameter("nickName");
				String date = request.getParameter("date");
				String center = request.getParameter("center");

				TgUsergrade usergrade = new TgUsergrade();
				if (!StringUtil.isEmpty(nickname)) {
					usergrade.setNickname2(nickname);
				}
				if (!StringUtil.isEmpty(date)) {
					usergrade.setDate(date);
				}
				Integer currPage = 1;
				if (vo.getCurrPage() != null && !"".equals(vo.getCurrPage())) {
					currPage = vo.getCurrPage();
				}
				usergrade.setAdd_username(add_username);
				Integer total = usergradeDao.getUsergradeCount(usergrade);
				Page page = PageUtil.createPage(8, currPage, total);
				List<TgUsergrade> list = usergradeDao.getUsergradelist(usergrade, page);

				TgUser user2 = new TgUser();
				user2.setJob("课程顾问");
				user2.setTypes("排除销售主管");
				user2.setIs_zhuanz("排除未转正");
				user2.setRegions(center);
				List<TgUser> ulist = userDao.getUserInfoByType2(user2);

				result.setDefaultModel("ulist", ulist);
				result.setDefaultModel("page", page);
				result.setDefaultModel("list", list);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 打分
	@RequestMapping(value = "/add_mark")
	public ModelAndView add_mark(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			HttpServletResponse response) throws BaseException {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String add_username = request.getParameter("add_username");
				String add_nickname = request.getParameter("add_nickname");
				String username = request.getParameter("username");
				String fraction = request.getParameter("fraction");
				String msg = request.getParameter("msg");

				TgUsergrade usergrade = new TgUsergrade();
				if (fraction != null && !"".equals(fraction)) {
					usergrade.setUsername(username);
					usergrade.setAdd_username(add_username);
					usergrade.setDate(DateUtil.lastMonth2());
					List<TgUsergrade> list = usergradeDao.findByExample(usergrade);
					if (list != null && list.size() > 0) {
						result.setDefaultModel("msg", "0");
					} else {
						usergrade.setType(2);
						usergrade.setAdd_nickname(add_nickname);
						usergrade.setFraction(Integer.valueOf(fraction));
						usergrade.setMsg(msg);
						usergrade.setCreate_time(new Date());
						usergradeDao.insert(usergrade);
						result.setDefaultModel("msg", "1");
					}

				}
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}
	/* end-------------------------------中心打分------------------------ */

	/**
	 * 训练 缴费信息
	 */
	@RequestMapping(value = "/getmoneyBytype")
	public ModelAndView getmoneyBytype(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String stu_name = request.getParameter("student");
				String stu_id = request.getParameter("stu_id");

				TgMoney money = new TgMoney();
				if (stu_name != null && !"".equals(stu_name)) {
					money.setStu_name(stu_name);
				}
				if (stu_id != null && !"".equals(stu_id)) {
					money.setStu_id(Long.valueOf(stu_id));
				}
				List<TgMoney> list = moneyDao.getMoneysByType2(money);
				result.setDefaultModel("list", list);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 上门费学员查询
	@RequestMapping(value = "/getmoneyBySm")
	public ModelAndView getmoneyBySm(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String stu_id = request.getParameter("stu_id");
				String stu_name = request.getParameter("stu_name");
				TgMoney money = new TgMoney();
				if (stu_id != null && !"".equals(stu_id)) {
					money.setStu_id(Long.valueOf(stu_id));
				}
				if (stu_name != null && !"".equals(stu_name)) {
					money.setStu_name(stu_name);
				}
				money.setPra_type(7);
				Page page = PageUtil.createPage(8, 1, 1);
				List<TgMoney> list = moneyDao.getMoneysByType(money, page);
				result.setDefaultModel("list", list);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	/**
	 * 训练系统试用期展现列表
	 * 
	 * @param modelMap
	 * @param vo
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/period_List")
	public ModelAndView period_List(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);

				String currPage = request.getParameter("currPage");
				String login_name = request.getParameter("login_name");
				String center = request.getParameter("center");
				String power = "";
				Map<String, Object> map = tgPeriodService.TgPeriodList(login_name, power, Integer.parseInt(currPage),
						center);
				result.setDefaultModel("list", map.get("list"));
				result.setDefaultModel("page", map.get("page"));
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	@RequestMapping(value = "/addPeriod_Show")
	public ModelAndView addPeriodShow(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				TgPeriod period = new TgPeriod();
				String username = request.getParameter("username");

				String id = request.getParameter("c_id");
				if (id != null && !"".equals(id) && !id.equals("null")) {// 表示修改
					period.setId(Long.valueOf(id));
					period = tgPeriodDao.findById(TgPeriod.class, Long.valueOf(id));
					result.setDefaultModel("period", period);
				} else if (username != null && !"".equals(username)) {// 表示添加
					period.setCreate_name(username);
					Integer currPage = 1;
					if (vo.getCurrPage() != null && !"".equals(vo.getCurrPage())) {
						currPage = vo.getCurrPage();
					}
					Integer total = tgPeriodDao.getPreCountByType(period);
					Page page = PageUtil.createPage(total, currPage, total);
					List<TgPeriod> list = tgPeriodDao.getPeriodByType(period, page);
					if (list != null && list.size() > 0) {
						period = list.get(0);
						result.setDefaultModel("period", period);
					} else {
						result.setDefaultModel("period", null);
					}

				}
				return result;

			}
		});
		return new ModelAndView("", modelMap);
	}

	// 添加员工反馈
	@RequestMapping(value = "/add_per")
	public ModelAndView addPer(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				TgPeriod period = new TgPeriod();
				String id = request.getParameter("c_id");
				String power = "";// 在训练系统中，不存在分配任务的情况，在每个月的十五号与20号之间评论或者修改
				String type = request.getParameter("type");
				String station = request.getParameter("station");
				String centre = request.getParameter("centre");
				String name = request.getParameter("name");
				String beizhu = request.getParameter("beizhu");
				String state = request.getParameter("state");
				String username = request.getParameter("username");
				String login_name = request.getParameter("login_name");
				if (type != null && !type.equals("")) {
					period.setType(Integer.parseInt(type));
				}
				if (state != null && !"".equals(state)) {
					period.setState(Integer.parseInt(state));
				}
				if (station != null && !"".equals(station)) {
					period.setStation(Integer.parseInt(station));
				}
				period.setBeizhu(beizhu);
				period.setUsername(username);
				period.setCentre(centre);
				period.setName(name);
				period.setCreate_name(login_name);
				period.setCreate_time(new Date());
				Map<String, String> map = tgPeriodService.TgPeriodAddPro(power, id, period);
				result.setDefaultModel("msg", map.get("msg"));
				return result;

			}
		});
		return new ModelAndView("", modelMap);
	}

	// 删除员工反馈
	@RequestMapping(value = "/delete_list")
	public ModelAndView delete_list(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				TgPeriod period = new TgPeriod();
				String id = request.getParameter("id");
				if (id != null && !"".equals(id)) {
					period.setId(Long.parseLong(id));
					tgPeriodDao.delete(period);
				}
				String currPage = request.getParameter("currPage");
				String login_name = request.getParameter("login_name");
				String center = request.getParameter("center");
				String power = "";
				Map<String, Object> map = tgPeriodService.TgPeriodList(login_name, power, Integer.parseInt(currPage),
						center);
				result.setDefaultModel("list", map.get("list"));
				result.setDefaultModel("page", map.get("page"));
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 查询区域主管下面的中心主任有多少人
	@RequestMapping(value = "/period_teacher1")
	public ModelAndView period_teacher1(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String city = request.getParameter("city");
				List<TgOffice> list = new ArrayList<TgOffice>();
				List<TgUserinfo> list2 = new ArrayList<TgUserinfo>();
				if (city != null && !"".equals(city)) {
					String citys[] = city.split(",");
					if (citys != null && citys.length > 0) {
						for (int i = 0; i < citys.length; i++) {
							TgOffice tgOffice = new TgOffice();
							tgOffice.setCity(citys[i]);
							List<TgOffice> list1 = tgOfficeDao.getCoreNameByCity2(tgOffice);
							if (list1 != null && list1.size() > 0) {
								list.addAll(list1);
							}
						}

					}
				}
				if (list != null && list.size() > 0) {
					for (int i = 0; i < list.size(); i++) {
						TgUserinfo userinfo = new TgUserinfo();
						userinfo.setRegion(list.get(i).getName());
						userinfo.setType(1);
						List<TgUserinfo> ls = userinfoDao.getUserInfoByUserInfo(userinfo);
						if (ls != null && ls.size() > 0) {
							list2.addAll(ls);
						}
					}

				}
				result.setDefaultModel("list", list2);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 中心主任列表
	@RequestMapping(value = "/zhurenlist")
	public ModelAndView zhurenlist(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String nickName = request.getParameter("nickName");
					String centName = request.getParameter("center");
					String type = request.getParameter("type");
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

					TgUserinfo userinfo = new TgUserinfo();
					if (nickName != null && !"".equals(nickName) && !"null".equals(nickName)) {
						userinfo.setNickname(nickName);
						result.setDefaultModel("nickName", nickName);
					}
					if (centName != null && !"".equals(centName) && !"null".equals(centName)) {
						userinfo.setRegion(centName);
						result.setDefaultModel("centName", centName);
					}
					if (type != null && !"".equals(type) && !"null".equals(type)) {
						userinfo.setType(Integer.valueOf(type));
						result.setDefaultModel("type", type);
					}
					Integer currPage = 1;
					if (vo.getCurrPage() != null && !"".equals(vo.getCurrPage())) {
						currPage = vo.getCurrPage();
					}

					Integer total = userinfoDao.getUserInfoCount(userinfo);
					Page page = PageUtil.createPage(8, currPage, total);
					List<TgUserinfo> list = userinfoDao.getUserInfoByUserName(userinfo, page);

					if (list != null && list.size() > 0) {
						TgUser u = new TgUser();
						for (TgUserinfo userInfo : list) {
							u.setUsername(userInfo.getUsername());
							List<TgUser> uList = userDao.findByExample(u);
							if (uList != null && uList.size() > 0) {
								if (uList.get(0).getCreatedate() != null && !"".equals(uList.get(0).getCreatedate())) {
									String createTime = sdf.format(new Date(uList.get(0).getCreatedate() * 1000));
									userInfo.setCreateTime(createTime);
								}
							}
						}
					}

					result.setDefaultModel("page", page);
					result.setDefaultModel("list", list);

					List<TgOffice> office_List = tgOfficeDao.findAll(TgOffice.class);
					result.setDefaultModel("office_List", office_List);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 是谁把这个员工招聘进来的;
	@RequestMapping(value = "/getrecruit")
	public ModelAndView getrecruit(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String t_id = request.getParameter("t_id");
				TgRecruitment recruitment = new TgRecruitment();
				if (t_id != null && !"".equals(t_id) && !"null".equals(t_id)) {
					recruitment.setName(t_id);
				}
				List<TgRecruitment> list = recruitmentDao.findByName(recruitment);
				result.setDefaultModel("list", list);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 保存员工转正审核
	@RequestMapping(value = "/add_tur")
	public ModelAndView add_tur(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				TgTurnover turnover = new TgTurnover();
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
				String id = request.getParameter("id");
				String center = request.getParameter("center");
				String zxzr = request.getParameter("zxzr");
				String teacherid = request.getParameter("teacherid");
				String gw = request.getParameter("gw");
				String rztime = request.getParameter("rztime");
				String zpls = request.getParameter("zpls");
				String zryj = request.getParameter("zryj");
				String beizhu1 = request.getParameter("beizhu1");
				String zgyj = request.getParameter("zgyj");
				String beizhu2 = request.getParameter("beizhu2");
				String status = request.getParameter("status");
				// String nexttime = request.getParameter("nexttime");
				String zzzztime = request.getParameter("zzzztime");
				try {
					turnover.setCenter(center);
					turnover.setZxzr(zxzr);
					turnover.setTeacherid(teacherid);
					turnover.setGw(gw);
					turnover.setRztime(rztime);
					turnover.setZpls(zpls);
					turnover.setZryj(Integer.parseInt(zryj));
					turnover.setBeizhu1(beizhu1);
					if (zgyj != null && !"".equals(zgyj)) {
						turnover.setZgyj(Integer.parseInt(zgyj));
						turnover.setBeizhu2(beizhu2);
					}
					turnover.setStatus(status);
					// turnover.setNexttime(sdf.parse(nexttime));
					turnover.setCdate(new Date());
					if (id != null && !"".equals(id)) {
						turnover.setId(Integer.valueOf(id));
						if (turnover.getZryj() != turnover.getZgyj()) {
							Date monthAdd = DateUtil.MonthAdd(sdf.parse(zzzztime), 1);
							turnover.setNexttime(monthAdd);
							turnover.setZzzztime(monthAdd);
						} else if (turnover.getZryj() == 3 || turnover.getZgyj() == 3) {
							turnover.setStatus("建议辞退");
						}
						boolean i = tgTurnoverDao.update(turnover);
						result.setDefaultModel("msg", i);
					} else {
						Date monthAdd = DateUtil.MonthAdd(sdf.parse(rztime), 6);
						turnover.setNexttime(monthAdd);
						turnover.setZzzztime(monthAdd);
						Long i = tgTurnoverService.AddTgTurnover(turnover);
						result.setDefaultModel("msg", i);
					}
				} catch (ParseException e) {
					e.printStackTrace();
				}
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 查看员工的转正情况
	@RequestMapping(value = "/turnover_list")
	public ModelAndView turnover_list(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				TgTurnover turnover = new TgTurnover();
				String currPage1 = request.getParameter("currPage");
				String login_name = request.getParameter("login_name");
				String id = request.getParameter("id");
				String center = request.getParameter("center");

				if (login_name != null && !"".equals(login_name)) {
					turnover.setZxzr(login_name);
				}
				if (id != null && !"".equals(id)) {
					turnover.setId(Integer.parseInt(id));
				}
				if (center != null && !"".equals(center)) {
					turnover.setCenter(center);
				}
				Integer currPage = currPage1 == null ? 1 : Integer.parseInt(currPage1);
				Integer total = tgTurnoverService.getPreCountByType(turnover);
				Page page = PageUtil.createPage(10, currPage, total);
				List<TgTurnover> list = tgTurnoverService.findTurnoverList(turnover, page);
				result.setDefaultModel("list", list);
				result.setDefaultModel("page", page);

				// Map<String,Object>map=tgPeriodService.TgPeriodList(login_name,power,Integer.parseInt(currPage),center);
				// result.setDefaultModel("list", map.get("list"));
				// result.setDefaultModel("page", map.get("page"));
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 查看员工的转正情况
	@RequestMapping(value = "/delete_turnover")
	public ModelAndView delete_turnover(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				TgTurnover turnover = new TgTurnover();
				String id = request.getParameter("id");
				turnover.setId(Integer.parseInt(id));
				tgTurnoverService.deleteId(turnover);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 缴费列表、不分页
	@RequestMapping(value = "/moneyListByType")
	public ModelAndView moneyListByType(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String stu_id = request.getParameter("stu_id");
				String startTime = request.getParameter("startTime");
				String endTime = request.getParameter("endTime");

				TgMoney money = new TgMoney();
				if (stu_id != null && !"".equals(stu_id) && !"null".equals(stu_id)) {
					money.setStu_id(Long.valueOf(stu_id));
				}
				if (startTime != null && !"".equals(startTime) && !"null".equals(startTime)) {
					money.setStartTime(startTime);
				}
				if (endTime != null && !"".equals(endTime) && !"null".equals(endTime)) {
					money.setEndTime(endTime);
				}

				List<TgMoney> list = moneyDao.getMoneysByType3(money);
				result.setDefaultModel("money", money);
				result.setDefaultModel("list", list);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	/**
	 * 获取所有的续费记录
	 * 
	 * @param vo
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getAllmoneySmtype")
	public ModelAndView getAllmoneySmtype(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String stu_name = request.getParameter("student");
					String stu_id = request.getParameter("stu_id");

					TgMoney money = new TgMoney();
					if (stu_name != null && !"".equals(stu_name)) {
						money.setStu_name(stu_name);
					}
					if (stu_id != null && !"".equals(stu_id)) {
						money.setStu_id(Long.valueOf(stu_id));
					}
					List<TgMoney> list = moneyDao.getAllMoneySmtype(money);
					result.setDefaultModel("list", list);

				} catch (Exception e) {
					e.printStackTrace();
				}

				return result;
			}

		});
		return new ModelAndView("", modelMap);
	}

	@RequestMapping(value = "/getmoneySmtype")
	public ModelAndView getmoneySmtype(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String stu_name = request.getParameter("student");
					String stu_id = request.getParameter("stu_id");
					String time = request.getParameter("time");
					String startTime = request.getParameter("startTime");
					String endTime = request.getParameter("endTime");

					if (time != null && !"".equals(time)) {

						startTime = sdf.format(DateUtil.getMonthFirst(time));

					} else {
						startTime = sdf.format(DateUtil.getMonthFirst(sdf.format(new Date())));
					}
					if (startTime != null && !"".equals(startTime)) {
						endTime = sdf.format(DateUtil.getMonthLast(startTime));
					}

					TgMoney money = new TgMoney();
					if (stu_name != null && !"".equals(stu_name)) {
						money.setStu_name(stu_name);
					}
					if (stu_id != null && !"".equals(stu_id)) {
						money.setStu_id(Long.valueOf(stu_id));
					}
					money.setStartTime(startTime);
					money.setEndTime(endTime);
					List<TgMoney> list = moneyDao.getMoneySmtype(money);
					result.setDefaultModel("list", list);

				} catch (Exception e) {
					e.printStackTrace();
				}

				return result;
			}

		});
		return new ModelAndView("", modelMap);
	}

	@RequestMapping(value = "/getmoneySm")
	public ModelAndView getmoneySm(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String stu_id = request.getParameter("stu_id");
					TgMoney money = new TgMoney();
					if (stu_id != null && !"".equals(stu_id)) {
						money.setStu_id(Long.valueOf(stu_id));
					}
					List<TgMoney> list = moneyDao.getMoneySmtype(money);
					result.setDefaultModel("list", list);

				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

				return result;
			}

		});
		return new ModelAndView("", modelMap);
	}
	/**
	 * @Title: 方法名：getmoneySm_new
	 * @Description: 功能描述：获取上门次数
	 * @author hqD ☺ ^o^
	 * @date 2018年1月29日 下午2:56:19
	 * @return ModelAndView    返回类型
	 */
	@RequestMapping(value = "/getmoneySm_new")
	public ModelAndView getmoneySm_new(HttpServletRequest request) {
		ModelAndView mav=new ModelAndView("");
		String stu_id = request.getParameter("stu_id");
		TgMoney money = moneyDao.getmoneySm_new(Long.valueOf(stu_id));
		mav.addObject("money",money);
		return mav;
	}

	// 人员情况统计表
	@RequestMapping(value = "/personnel_list")
	public ModelAndView personnel_list(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String center = request.getParameter("center");
				String login_name = request.getParameter("login_name");

				TgPersonnelState tgPersonnelState = new TgPersonnelState();
				if (center != null && !"".equals(center)) {
					tgPersonnelState.setCenter(center);
				}
				if (!login_name.equals("system")) {
					tgPersonnelState.setLogin_name(login_name);
				}
				Integer currPage = vo.getCurrPage() == null ? 1 : vo.getCurrPage();
				Integer total = personnelStateDao.getCountPersonnelStateByType(tgPersonnelState);
				Page page = PageUtil.createPage(10, currPage, total);
				List<TgPersonnelState> list = personnelStateDao.getPersonnelStateByType(tgPersonnelState, page);

				if (list != null && list.size() > 0) {
					for (int i = 0; i < list.size(); i++) {
						List<TgPersonnelState> li = personnelStateDao.getPersonnelStateByType1(list.get(i));
						if (li != null && li.size() > 0) {
							for (int j = 0; j < li.size(); j++) {
								li.get(j).setCenter("");
							}
							list.get(i).setPersonnelList(li);

						}

					}
				}
				result.setDefaultModel("page", page);
				result.setDefaultModel("list", list);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 进入添加人员情况
	@RequestMapping(value = "/add_personnel")
	public ModelAndView add_personnel(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("id");
				if (id != null && !id.equals("")) {
					TgPersonnelState tgPersonnelState = personnelStateDao.findById(TgPersonnelState.class,
							Long.parseLong(id));
					result.setDefaultModel("tgPersonnelState", tgPersonnelState);
				} else {
					result.setDefaultModel("tgPersonnelState", new TgPersonnelState());
				}
				return result;

			}
		});
		return new ModelAndView("", modelMap);
	}

	// 保存人员情况
	@RequestMapping(value = "/addPersonnel")
	public ModelAndView addPersonnel(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("id");
				String station = request.getParameter("station");
				String center = request.getParameter("center");
				String name = request.getParameter("name");
				String beizhu = request.getParameter("beizhu");
				String teacher_state = request.getParameter("teacher_state");
				String login_name = request.getParameter("login_name");
				TgPersonnelState tgPersonnelState = new TgPersonnelState();
				tgPersonnelState.setBeizhu(beizhu);
				tgPersonnelState.setName(name);
				tgPersonnelState.setLogin_name(login_name);
				tgPersonnelState.setCenter(center);
				if (teacher_state != null && !"".equals(teacher_state)) {
					tgPersonnelState.setTeacher_state(Integer.parseInt(teacher_state));
				}
				if (station != null && !"".equals(station)) {
					tgPersonnelState.setStation(Integer.parseInt(station));
				}
				if (id != null && !"".equals(id)) {
					tgPersonnelState.setId(Long.parseLong(id));
					tgPersonnelState.setCreate_time(DateUtil.getDate());
					personnelStateDao.update(tgPersonnelState);
				} else {
					tgPersonnelState.setCreate_time(DateUtil.getDate());
					personnelStateDao.insert(tgPersonnelState);
				}
				result.setDefaultModel("msg", "1");
				return result;

			}
		});
		return new ModelAndView("", modelMap);
	}

	@RequestMapping(value = "/period_teacher")
	public ModelAndView period_teacher(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String center = request.getParameter("center");
				String locked = request.getParameter("locked");
				List<TgUser> list = new ArrayList<TgUser>();
				if (center != null && !center.equals("")) {
					TgUser user = new TgUser();
					user.setRegions(center);
					if (locked != null && !"".equals(locked)) {
						user.setLocked(Integer.parseInt(locked));
					}
					list = userDao.getUserInfoByType3(user);
				}
				result.setDefaultModel("list", list);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	@RequestMapping(value = "/result_list")
	public ModelAndView result_list(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String center = request.getParameter("center");
				String currPage = request.getParameter("currPage");
				Integer curr = 1;
				if (currPage != null && !currPage.equals("")) {
					curr = Integer.parseInt(currPage);
				}
				TgRecruitmentResult tgRecruitmentResult = new TgRecruitmentResult();
				tgRecruitmentResult.setCenter(center);

				Integer total = recruitmentResultDao.getTgCountRecruitResultByType(tgRecruitmentResult);
				Page page = PageUtil.createPage(10, curr, total);
				List<TgRecruitmentResult> list = recruitmentResultDao.getTgRecruitResultByType(tgRecruitmentResult,
						page);
				result.setDefaultModel("list", list);
				result.setDefaultModel("page", page);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	@RequestMapping(value = "/add_result")
	public ModelAndView add_result(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String center = request.getParameter("center");
				String id = request.getParameter("id");

				List<TgRecruitment> list = new ArrayList<TgRecruitment>();
				TgRecruitmentResult tgRecruitmentResult = new TgRecruitmentResult();
				TgRecruitment tgRecruitment = new TgRecruitment();
				if (center != null && !center.equals("")) {
					tgRecruitment.setCenter(center);
				}
				tgRecruitment.setSuccess(1);

				if (id != null && !"".equals(id)) {
					tgRecruitment.setId(Long.parseLong(id));
					tgRecruitmentResult = recruitmentResultDao.findById(TgRecruitmentResult.class, Long.parseLong(id));
					if (tgRecruitmentResult.getRecruitment_id() != null) {
						TgRecruitment Recruitment = recruitmentDao.findById(TgRecruitment.class,
								tgRecruitmentResult.getRecruitment_id());
						tgRecruitmentResult.setName(Recruitment.getName());

					}
					result.setDefaultModel("tgRecruitmentResult", tgRecruitmentResult);
				} else {
					list = recruitmentDao.getTgRecruitmentByType1(tgRecruitment);
					result.setDefaultModel("list", list);
				}

				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 保存中心主任老师填写的面试详情
	@RequestMapping(value = "/addResult")
	public ModelAndView addResult(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);

				String id = request.getParameter("id");

				String res = request.getParameter("result");
				String recruitment_id = request.getParameter("recruitment_id");
				String beizhu = request.getParameter("beizhu");
				String details = request.getParameter("details");

				TgRecruitmentResult tgRecruitmentResult = new TgRecruitmentResult();
				if (recruitment_id == null || "".equals(recruitment_id)) {
					result.setDefaultModel("msg", "2");
				} else {
					tgRecruitmentResult.setRecruitment_id(Long.parseLong(recruitment_id));
					if (res != null && "".equals(res)) {
						tgRecruitmentResult.setResult(Integer.parseInt(res));
					}
					tgRecruitmentResult.setBeizhu(beizhu);
					tgRecruitmentResult.setDetails(details);
					if (id == null || "".equals(id)) {
						recruitmentResultDao.insert(tgRecruitmentResult);
					} else {
						tgRecruitmentResult.setId(Long.parseLong(id));
						recruitmentResultDao.update(tgRecruitmentResult);
					}
					result.setDefaultModel("msg", "1");
				}
				return result;

			}
		});
		return new ModelAndView("", modelMap);
	}

	@RequestMapping(value = "/quit_list")
	public ModelAndView quit_list(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String fill_in_nickname = request.getParameter("fill_in_nickname");
				String currPage = request.getParameter("currPage");
				String username = request.getParameter("username");
				TgQuit quit = new TgQuit();
				Integer curr = 1;
				if (currPage != null && !currPage.equals("")) {
					curr = Integer.parseInt(currPage);
				}
				if (fill_in_nickname != null && !"".equals(fill_in_nickname)) {
					quit.setFill_in_nickname(fill_in_nickname);
				}
				if (username != null && !"".equals(username)) {
					quit.setUsername(username);
				}
				Integer total = quitDao.getCountQuitByType(quit);
				Page page = PageUtil.createPage(10, curr, total);
				List<TgQuit> list = quitDao.getQuitByType(quit, page);
				result.setDefaultModel("list", list);
				result.setDefaultModel("page", page);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	@RequestMapping(value = "/add_quit")
	public ModelAndView add_quit(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("id");
				if (id != null && !"".equals(id)) {
					TgQuit quit = quitDao.findById(TgQuit.class, Long.parseLong(id));
					result.setDefaultModel("quit", quit);
				}
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	@RequestMapping(value = "/addQuit")
	public ModelAndView addQuit(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String id = request.getParameter("id");
					String username = request.getParameter("name");
					String login_name = request.getParameter("login_name");
					String post = request.getParameter("post");
					String center = request.getParameter("center");
					String reason = request.getParameter("reason");
					String paid_in_accordance = request.getParameter("paid_in_accordance");
					String type = request.getParameter("type");
					String phone = request.getParameter("phone");
					String induction_time = request.getParameter("induction_time");
					String departure_time = request.getParameter("departure_time");
					String social_security = request.getParameter("social_security");
					String beizhu = request.getParameter("beizhu");
					String sex = request.getParameter("sex");
					String fill_in_name = request.getParameter("fill_in_name");
					String fill_in_nickname = request.getParameter("fill_in_nickname");
					String work_clothes = request.getParameter("work_clothes");
					String email = request.getParameter("email");
					TgQuit quit = new TgQuit();
					quit.setUsername(username);
					quit.setLogin_name(login_name);
					quit.setPost(post);
					quit.setCenter(center);
					quit.setReason(reason);
					if (paid_in_accordance != null && !"".equals(paid_in_accordance)) {
						quit.setPaid_in_accordance(Integer.parseInt(paid_in_accordance));
					}
					if (type != null && !"".equals(type)) {
						quit.setType(Integer.parseInt(type));
					}
					quit.setPhone(phone);
					if (departure_time != null && !"".equals(departure_time)) {
						quit.setDeparture_time(sdf.parse(departure_time));
					}
					if (induction_time != null & !"".equals(induction_time)) {
						quit.setInduction_time(sdf.parse(induction_time));
					}
					if (social_security != null && !"".equals(social_security)) {
						quit.setSocial_security(Integer.parseInt(social_security));
					}
					if (sex != null && !"".equals(sex)) {
						quit.setSex(Integer.parseInt(sex));
					}
					if (work_clothes != null && !"".equals(work_clothes)) {
						quit.setWork_clothes(Integer.parseInt(work_clothes));
					}
					if (email != null && !"".equals(email)) {
						quit.setEmail(email);
					}
					quit.setFill_in_name(fill_in_name);
					quit.setFill_in_nickname(fill_in_nickname);
					quit.setBeizhu(beizhu);
					if (id != null && !"".equals(id)) {
						quit.setId(Long.parseLong(id));
						quitDao.update(quit);
					} else {
						quitDao.insert(quit);
					}
					result.setDefaultModel("msg", 1);
				} catch (ParseException e) {
					e.printStackTrace();
				}
				return result;

			}
		});
		return new ModelAndView("", modelMap);
	}

	// 物品发放
	@RequestMapping(value = "/good_provide_list")
	public ModelAndView good_provide_list(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String handle_person = request.getParameter("handle_person");
				String currPage = request.getParameter("currPage");
				String username = request.getParameter("username");
				String center = request.getParameter("center");
				TgGoodProvide goodProvide = new TgGoodProvide();
				Integer curr = 1;
				if (currPage != null && !currPage.equals("")) {
					curr = Integer.parseInt(currPage);
				}
				if (handle_person != null && !"".equals(handle_person)) {
					goodProvide.setHandle_person(handle_person);
				}
				if (center != null && !"".equals(center)) {
					goodProvide.setCenter(center);
				}
				if (username != null && !"".equals(username)) {
					goodProvide.setUsername(username);
				}
				Integer total = goodProvideDao.getCountGoodProvideByType(goodProvide);
				Page page = PageUtil.createPage(10, curr, total);
				List<TgGoodProvide> list = goodProvideDao.getGoodProvideByType(goodProvide, page);
				result.setDefaultModel("list", list);
				result.setDefaultModel("page", page);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	@RequestMapping(value = "/add_good")
	public ModelAndView add_good(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("id");
				if (id != null && !id.equals("")) {
					TgGoodProvide good = goodProvideDao.findById(TgGoodProvide.class, Long.parseLong(id));
					result.setDefaultModel("good", good);
				}
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	@RequestMapping(value = "/addGood")
	public ModelAndView addGood(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("id");
				String login_name = request.getParameter("login_name");
				String post = request.getParameter("post");
				String center = request.getParameter("center");
				String good = request.getParameter("good");
				String department = request.getParameter("department");
				String handle_person = request.getParameter("handle_person");
				String date_of_entry = request.getParameter("date_of_entry");
				String date_of_regist = request.getParameter("date_of_regist");
				String username = request.getParameter("name");
				String beizhu = request.getParameter("beizhu");
				TgGoodProvide goodProvide = new TgGoodProvide();
				goodProvide.setCenter(center);
				goodProvide.setBeizhu(beizhu);
				goodProvide.setHandle_person(handle_person);
				goodProvide.setLogin_name(login_name);
				goodProvide.setUsername(username);
				goodProvide.setGood(good);
				goodProvide.setDate_of_entry(date_of_entry);
				goodProvide.setDate_of_regist(date_of_regist);
				goodProvide.setPost(post);
				goodProvide.setDepartment(department);

				if (id != null && !"".equals(id)) {
					goodProvide.setId(Long.parseLong(id));
					goodProvideDao.update(goodProvide);
				} else {
					goodProvide.setCreate_time(new Date());
					goodProvideDao.insert(goodProvide);
				}
				result.setDefaultModel("msg", 1);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 抽奖

	@RequestMapping(value = "/add_cj")
	public ModelAndView add_cj(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("id");
				if (id != null && !id.equals("")) {
					ChouJiang cj = cjDao.findById(ChouJiang.class, Long.parseLong(id));
					result.setDefaultModel("cj", cj);
				}
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	@RequestMapping(value = "/addCj")
	public ModelAndView addCj(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("id");
				String name = request.getParameter("name");
				String type = request.getParameter("type");
				String prizes = request.getParameter("prizes");
				String title = request.getParameter("title");
				String center = request.getParameter("center");
				ChouJiang cj = new ChouJiang();
				TgUserinfo userinfo = new TgUserinfo();
				if (name != null && !"".equals(name)) {
					cj.setName(name);
					userinfo.setNickname(name);
					List<TgUserinfo> list = userinfoDao.getUserlistByType(userinfo);
					if (list != null && list.size() > 0) {
						cj.setTea_id(list.get(0).getId());
						cj.setCenter(list.get(0).getRegions());
					}
				}
				if (center != null && !"".equals(center)) {
					cj.setCenter(center);
				}
				if (prizes != null && !"".equals(prizes)) {
					cj.setPrizes(prizes);
				}
				if (title != null && !"".equals(title)) {
					cj.setTitle(title);
				}
				cj.setType(Integer.valueOf(type));
				if (id != null && !"".equals(id)) {
					cj.setId(Long.parseLong(id));
					cjDao.update(cj);
				} else {
					cj.setCreate_time(new Date());
					cjDao.insert(cj);
				}
				result.setDefaultModel("msg", 1);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	@RequestMapping(value = "/chouj2")
	public Map<String, Object> chouj2(ModelMap model, HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object> ms = new HashMap<String, Object>();
		String name = request.getParameter("name");
		String username = request.getParameter("username");
		String center = request.getParameter("center");
		ChouJiang cj = new ChouJiang();
		if (center != null && !"".equals(center)) {
			cj.setCenter(center);
		}
		if (name != null && !"".equals(name)) {
			cj.setName(name);
		}
		if (username != null && !"".equals(username)) {
			cj.setUsername(username);
		}

		List<ChouJiang> list = cjDao.getCjByName(cj);
		if (list != null && list.size() > 0) {
			for (ChouJiang cjj : list) {
				cjj.setDenj_time(sdf2.format(cjj.getCreate_time()));
			}
		}
		ms.put("list", list);

		JSONObject resultJSON = JSONObject.fromObject(ms); // 根据需要拼装json
		String jsonpCallback = request.getParameter("callback");// 客户端请求参数
		OutputStream ouputStream;
		try {
			ouputStream = response.getOutputStream();
			ouputStream.write((jsonpCallback + "(" + resultJSON.toString() + ")").getBytes());
			ouputStream.flush();
			ouputStream.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return ms;
	}

	// 按中心名和或老师名字查询课程顾问
	@RequestMapping(value = "/getKeChengGuWen")
	public ModelAndView getKeChengGuWen(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String center = request.getParameter("center");
				String tea_name = request.getParameter("tea_name");
				TgUserinfo userinfo = new TgUserinfo();
				if (center != null && !"".equals(center)) {
					userinfo.setCenter(center);
				}
				if (tea_name != null && !"".equals(tea_name)) {
					userinfo.setNickname(tea_name);
				}
				List<TgUserinfo> list = userinfoDao.getKeChengGuWen(userinfo);
				result.setDefaultModel("list", list);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}
	/**
	 * @Title: 方法名：getKeChengGuWen_ByCity
	 * @Description: 功能描述：获取城市下所有的课程顾问
	 * @author hqD ☺ ^o^
	 * @date 2017年12月22日 下午1:40:56
	 * @param @param request
	 * @param @param city
	 * @param @return    
	 * @return ModelAndView    返回类型
	 */
	@RequestMapping(value = "/getKeChengGuWen_ByCity")
	public ModelAndView getKeChengGuWen_ByCity(HttpServletRequest request,String city) {
		ModelAndView mav=new ModelAndView("");
		List<TgUserinfo> list = userinfoDao.getKeChengGuWen_ByCity(city);
		mav.addObject("list",list);
		return mav;
	}

	// 预约数据查询
	@RequestMapping(value = "/client_reserve_list")
	public ModelAndView client_reserve_list(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			HttpServletResponse response) throws BaseException {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String nickname = request.getParameter("name");
				String receptioner = request.getParameter("tea_name");
				String address = request.getParameter("address");
				String phone = request.getParameter("phone");
				String email = request.getParameter("email");
				String qq = request.getParameter("qq");
				String sdate = request.getParameter("sdate");
				String edate = request.getParameter("edate");
				String region = request.getParameter("region");
				String state = request.getParameter("state");
				String is_signer = request.getParameter("is_signer");
				String is_receptioner = request.getParameter("is_receptioner");
				String reserve_ns = request.getParameter("reserve_ns");
				String source = request.getParameter("source");
				String weixin = request.getParameter("weixin");

				TgUser user = UserUtil.getUserFromCookies();
				TgReserve reserve = new TgReserve();

				if (nickname != null && !"".equals(nickname)) {
					reserve.setNickname(nickname);
				}
				if (weixin != null && !"".equals(weixin)) {
					reserve.setWeixin(weixin);
				}
				if (address != null && !"".equals(address)) {
					reserve.setAdcity(address);
				}
				if (reserve_ns != null && !"".equals(reserve_ns)) {
					reserve.setReserve_ns(reserve_ns);
				}
				if (receptioner != null && !"".equals(receptioner)) {
					reserve.setReceptioner(receptioner);
				}
				if (qq != null && !"".equals(qq)) {
					reserve.setQq(qq);
				}
				if (email != null && !"".equals(email)) {
					reserve.setEmail(email);
				}
				if (phone != null && !"".equals(phone)) {
					reserve.setPhone(phone);
				}
				if (region != null && !"".equals(region)) {
					reserve.setRegionns(region);
				}
				if (region != null && !"null".equals(region) && !"".equals(region)) {
                	if(region.equals("成都桐梓林中心")) {
                		reserve.setRegionns("成都桐梓(zǐ)林中心");
                	}else if(region.equals("广州区庄中心")) {
                		reserve.setRegionns("广州区(ōu)庄中心");
                	}
                }
				if (state != null && !"".equals(state)) {
					int stat = Integer.parseInt(state);
					reserve.setState(stat);
				}
				if (is_signer != null && is_signer.equals("1")) {
					reserve.setUsername(user.getUsername());
				}
				if (is_receptioner != null && is_receptioner.equals("1")) {
					reserve.setReception_u(user.getUsername());
				}
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
				SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				if (sdate != null && !"".equals(sdate)) {
					try {
						reserve.setSdate(sdf.parse(sdate));
					} catch (ParseException e) {
						e.printStackTrace();
					}
				}
				if (edate != null && !"".equals(edate)) {
					try {
						reserve.setEdate(sdf.parse(edate));
					} catch (ParseException e) {
						e.printStackTrace();
					}
				}
				if (source != null && !"".equals(source)) {
					reserve.setSourcens(source);
				}

				Integer currPage = 1;
				if (vo.getCurrPage() != null && !"".equals(vo.getCurrPage())) {
					currPage = vo.getCurrPage();
				}
				Integer total = reserveDao.getReserveCount(reserve);
				Page page = PageUtil.createPage(8, currPage, total);
				List<TgReserve> list = reserveDao.getReserveList(reserve, page);

				result.setDefaultModel("nickname", nickname);
				result.setDefaultModel("receptioner", receptioner);
				result.setDefaultModel("address", address);
				result.setDefaultModel("sdate", sdate);
				result.setDefaultModel("edate", edate);
				result.setDefaultModel("region", region);
				result.setDefaultModel("state", state);
				result.setDefaultModel("is_signer", is_signer);
				result.setDefaultModel("is_receptioner", is_receptioner);
				result.setDefaultModel("source", source);
				result.setDefaultModel("list", list);
				result.setDefaultModel("page", page);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	// 添加缴费记录
	@RequestMapping(value = "/addMoenys")
	public ModelAndView getMoenys(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				// String id = request.getParameter("id");
				String stu_id = request.getParameter("stu_id");
				String center = request.getParameter("center");
				String teach_name1 = request.getParameter("teach_name1");
				String teach_name2 = request.getParameter("teach_name2");
				String tea_name = request.getParameter("tea_name");
				String stu_name = request.getParameter("stu_name");
				String pra_type = request.getParameter("pra_type");
				String times1 = request.getParameter("times1");
				String times2 = request.getParameter("times2");
				String s_pra = request.getParameter("s_pra");
				String moneyType1 = request.getParameter("moneyType1");
				String moneyType2 = request.getParameter("moneyType2");
				String moneyType3 = request.getParameter("moneyType3");
				String smf_c = request.getParameter("smf_c");
				String smf_m = request.getParameter("smf_m");
				String moneyDate = request.getParameter("moneyDate");
				String moneys = request.getParameter("moneys");
				String fp_moneys = request.getParameter("fp_moneys");
				String is_fapiao = request.getParameter("is_fapiao");
				String fp_tt = request.getParameter("fp_tt");
				String is_otkj = request.getParameter("is_otkj");
				String is_zqkj = request.getParameter("is_zqkj");
				String is_jj = request.getParameter("is_jj");
				String beizhu = request.getParameter("beizhu");
				String fw_urls = request.getParameter("fw_urls");
				String pz_urls = request.getParameter("pz_urls");
				String username = request.getParameter("username");

				TgMoney money = new TgMoney();
				// 接待老师 存入的是拼音
				TgUserinfo userinfo_0 = new TgUserinfo();
				TgUserinfo userinfo_1 = new TgUserinfo();
				if (MathUtil.isNotEmpty(teach_name1)) {
					userinfo_0.setUsername(teach_name1);
					List<TgUserinfo> userInfos = userInfoDao.findByExample(userinfo_0);
					if (userInfos.size() > 0) {
						teach_name1 = userInfos.get(0).getUsername();
					} else {
						return result;
					}
				}
				if (MathUtil.isNotEmpty(teach_name2)) {
					userinfo_1.setUsername(teach_name2);
					List<TgUserinfo> userInfos = userInfoDao.findByExample(userinfo_1);
					if (userInfos.size() > 0) {
						teach_name2 = userInfos.get(0).getUsername();
					} else {
						return result;
					}
				}
				// 如果 stu_id 后两位为 99 则 去掉 99 (直接去掉后面的俩个数字)
				stu_id = stu_id.substring(0, stu_id.length() - 2);

				money.setStu_id(Long.valueOf(stu_id));
				money.setJd_username1(teach_name1);
				money.setJd_username2(teach_name2);
				money.setUsername(username);
				money.setRecord_teacher(tea_name);
				money.setStudent(stu_name);
				money.setPra_type(Integer.valueOf(pra_type));
				if (pra_type.equals("5")) {
					money.setTimes(Integer.valueOf(times2));
				} else {
					money.setTimes(Integer.valueOf(times1));
				}
				money.setS_pra(s_pra);
				money.setMoneyType1(Integer.valueOf(moneyType1));
				money.setMoneyType2(Integer.valueOf(moneyType2));
				money.setSmf_c(smf_c);
				money.setSmf_m(smf_m);
				money.setMoneyDate(moneyDate);
				money.setMoneys(Double.valueOf(moneys));
				money.setFp_moneys(Double.valueOf(fp_moneys));
				money.setIs_fapiao(Integer.valueOf(is_fapiao));
				if (is_fapiao.equals("1")) {
					money.setFp_tt(fp_tt);
					money.setIs_otkj(Integer.valueOf(is_otkj));
					money.setIs_zqkj(Integer.valueOf(is_zqkj));
					money.setIs_jj(Integer.valueOf(is_jj));
				}
				money.setBeizhu(beizhu);
				money.setJd_center_key(center);
				money.setFw_url(fw_urls);
				money.setPz_url(pz_urls);
				if (center != null && !center.equals("")) {
					TgOffice office = new TgOffice();
					office.setKeyname(center);
					List<TgOffice> list = tgOfficeDao.findByExample(office);
					if (list != null && list.size() > 0) {
						office = list.get(0);
						TgMethod method = new TgMethod();
						method.setCenter_id(office.getId());
						if (moneyType3.equals("1")) {
							method.setName("现金");
						} else if (moneyType3.equals("2")) {
							method.setName("POS刷卡");
						} else if (moneyType3.equals("3")) {
							method.setName("支付宝");
						} else if (moneyType3.equals("4")) {
							method.setName("银行转账");
						}
						List<TgMethod> mList = methodDao.findByExample(method);
						if (mList != null && mList.size() > 0) {
							TgMethod meth = mList.get(0);
							money.setMethod_id(meth.getId());
						}
					}
				}

				if (money.getStu_id() != null && !"".equals(money.getStu_id())) {
					money.setStu_id(Long.valueOf(money.getStu_id()));
				}
				money.setCreate_time(new Date());
				moneyDao.insert(money);

				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	/**
	 * @Title: 方法名：getYy_JdCenter
	 * @Description: 功能描述：获取当日 城市 下中心的名称
	 * @author hqD ☺ ^o^
	 * @date 2017年12月18日 上午11:30:23
	 * @param @param
	 *            request
	 * @param @param
	 *            province
	 * @param @param
	 *            startTime
	 * @param @return
	 * @return ModelAndView 返回类型
	 */
	@RequestMapping(value = "/getYy_JdCenter")
	public ModelAndView getYy_JdCenter(HttpServletRequest request, String province, String startTime) {
		ModelAndView mav = new ModelAndView("");
		List<String> reserves = reserveDao.getYy_JdCenter(province, startTime);
		mav.addObject("reserves", reserves);
		return mav;
	}

	/**
	 * @Title: 方法名：getYy_JdTeacher
	 * @Description: 功能描述：获取预约接待的老师（时间，中心keyname，老师姓名）
	 * @author hqD ☺ ^o^
	 * @date 2017年12月18日 下午2:11:26
	 * @param @param
	 *            request
	 * @param @param
	 *            province
	 * @param @param
	 *            startTime
	 * @param @return
	 * @return ModelAndView 返回类型
	 */
	@RequestMapping(value = "/getYy_JdTeacher")
	public ModelAndView getYy_JdTeacher(HttpServletRequest request, String province, String startTime) {
		ModelAndView mav = new ModelAndView("");
		List<String> reserveTeas = reserveDao.getYy_JdTeacher(province, startTime);
		mav.addObject("reserveTeas", reserveTeas);
		return mav;
	}

	/**
	 * @Title: 方法名：getReserveUser
	 * @Description: 功能描述：获取预约接待老师
	 * @author hqD ☺ ^o^
	 * @date 2017年12月18日 下午4:28:02
	 * @param @param modelMap
	 * @param @param vo
	 * @param @param request
	 * @param @param response
	 * @param @return
	 * @param @throws BaseException    
	 * @return ModelAndView    返回类型
	 */
	@RequestMapping(value = "/getReserveUser")
	public ModelAndView getReserveUser(ModelMap modelMap, final BaseVo vo, final HttpServletRequest request,
			HttpServletResponse response) throws BaseException {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String date = request.getParameter("date");
					String time = request.getParameter("time");
					String needtime = request.getParameter("needtime");
					String region = request.getParameter("region");
					//String key = request.getParameter("key");
					String exclude = "";
					/*if (key != null) {
						exclude = "AND keyname!='" + key + "'";
					}*/
					TgUserinfo userinfo = new TgUserinfo();
					String stamp_l = "";
					Long stamp_r = null;
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
					if (date != null && !"".equals(date) && time != null) {
						stamp_l = date + " " + time;
						Long st_l = sdf.parse(stamp_l).getTime() / 1000;
						stamp_r = st_l;
						if (needtime != null && !"".equals(needtime)) {
							stamp_r = st_l + (long) (Double.valueOf(needtime) * 3600);
						}

						userinfo.setRegion(region);
						userinfo.setStamp_l1(st_l);
						userinfo.setStamp_r1(stamp_r);
						userinfo.setStamp_l2(st_l);
						userinfo.setStamp_r2(stamp_r);
						userinfo.setExclude(exclude);
					}
					List<TgUserinfo> list = userinfoDao.getReseUser(userinfo);
					result.setDefaultModel("stuList", list);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}
	/**
	 * @Title: 方法名：updateReserve_Tea
	 * @Description: 功能描述：更新预约接待老师及时间
	 * @author hqD ☺ ^o^
	 * @date 2017年12月19日 上午9:52:31
	 * @param @param request
	 * @param @param Id
	 * @param @param teaName
	 * @param @param time
	 * @param @return    
	 * @return ModelAndView    返回类型
	 */
	@RequestMapping(value = "/updateReserve_Tea")
	public ModelAndView updateReserve_Tea(HttpServletRequest request,String Id,String teaName,String time) {
		ModelAndView mav=new ModelAndView("");
		String flag = "false";
		TgReserve reserve = reserveDao.getTg_reserve_Id(Id);
		if(reserve !=  null) {
			reserve.setReception_u(teaName);
			reserve.setTime(time);
			reserveDao.update(reserve);
			flag = "true";
		}
		mav.addObject("flag",flag);
		return mav;
	}

	@RequestMapping(value = "/goodsMnus")
    public ModelAndView goodsMnus(ModelMap modelMap, final BaseVo vo,
       final HttpServletRequest request, HttpServletResponse response)
            throws BaseException {
        modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
            public Result process() {
                Result result = new ResultSupport(true);
                String id = request.getParameter("good_mnus");
                GoodsMnus gm = new GoodsMnus();
                if(id!=null && !"".equals(id)){
                	gm.setParint_id(Integer.valueOf(id));
                	List<GoodsMnus> list = goodsMnusDao.getGoodsmnus(gm);
                	result.setDefaultModel("list",list);
                }
                return result;
            }
        });
        return new ModelAndView("", modelMap);
    }
	//采购物品申请添加
	@RequestMapping(value = "/add_goods_go")
	public ModelAndView add_goods_go(ModelMap modelMap, final BaseVo vo,
			final HttpServletRequest request, HttpServletResponse response)
					throws BaseException {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
			 try {
				String goodid = request.getParameter("goodid");
				String goods_child_id = request.getParameter("goods_child_id");
				 String centerName = request.getParameter("centerName");
				 String good_muns_id = request.getParameter("good_muns_id");//物品分类
				 String good_pard_id = request.getParameter("good_pard_id");
				 String type = request.getParameter("type");                    //固定资产
				 String itemName = request.getParameter("itemName");
				 String number = request.getParameter("number");
				 String unitPrice = request.getParameter("unitPrice");
				 String totalCalculation = request.getParameter("totalCalculation");
				 String company = request.getParameter("company");            //单位
				 String msg = request.getParameter("msg");
				 String region = request.getParameter("region");
				 String code = request.getParameter("code");
				 String model = request.getParameter("model");
				 String purchasing_link = request.getParameter("purchasing_link");
				 String broadband_type = request.getParameter("broadband_type");
				 String supplier = request.getParameter("supplier");
				 String img_url = request.getParameter("img_url");
				 String squser = request.getParameter("squser");
				 String username = request.getParameter("tea_Name");
				 String purchaser = request.getParameter("purchaser");
				 
				 Date date = new Date();
				 GoodsNew goodn = new GoodsNew();
				 
				 if (goods_child_id != null && !"".equals(goods_child_id)) {
				 	goodn.setGoods_child_id(goods_child_id);
				 }
				 if (code != null && !"".equals(code)) {
					 goodn.setCode(code);
				 }
				 if (model != null && !"".equals(model)) {
				 	goodn.setModel(model);
				 }
				 if (img_url != null && !"".equals(img_url)) {
				 	goodn.setImg_url(img_url);
				 }
				 if (purchasing_link != null && !"".equals(purchasing_link)) {
				 	goodn.setPurchasing_link(purchasing_link);
				 }
				 if (broadband_type != null && !"".equals(broadband_type)) {
				 	goodn.setBroadband_type(broadband_type);
				 }
				 if (supplier != null && !"".equals(supplier)) {
				 	goodn.setSupplier(supplier);
				 }
				 if (number != null && !"".equals(number)) {
				 	goodn.setNumber(Integer.valueOf(number));
				 }
				 if (unitPrice != null && !"".equals(unitPrice)) {
				 	goodn.setUnit_price(Double.valueOf(unitPrice));
				 }
				 if (totalCalculation != null && !"".equals(totalCalculation)) {
				 	goodn.setTotal_calculation(Double.valueOf(totalCalculation));
				 }
				 if (type != null && !"".equals(type)) {
					 goodn.setType(Integer.valueOf(type));
				 }
				 if (good_muns_id != null && !"".equals(good_muns_id)) {
					 goodn.setGood_muns_id(Long.valueOf(good_muns_id));
				 }
				 if (good_pard_id != null && !"".equals(good_pard_id)) {
					 goodn.setGood_pard_id(Long.valueOf(good_pard_id));
				 }
				 goodn.setCenter_name(centerName);
				 goodn.setSq_user(squser);
				 goodn.setItem_name(itemName);
				 
				 goodn.setCompany(company);
				 goodn.setMsg(msg);
				 goodn.setRegion(region);
				 goodn.setUsername(username);
				 goodn.setApplied(1);//表示是申请
				 goodn.setApply_status(1);//审核状态 1未审核，2 ，审核通过
				 goodn.setCreate_time(DateUtil.formatDate(date, "yyyy-MM-dd HH:mm:ss"));
				 goodn.setPurchaser(purchaser);;
				 if(goodid!=null && !"".equals(goodid)){
				 	GoodsNew good = goodsNewDao.findById(GoodsNew.class, Long.valueOf(goodid));
				 	if(good!=null){
				 		goodn.setId(Long.valueOf(goodid));
				 		goodsNewDao.update(goodn);
				 		result.setDefaultModel("msg", "1");
				 		result.setDefaultModel("goodid", goodid);
				 	}
				 }else{
					goodn.setApply_status(1);
				 	Long id=goodsNewDao.insert(goodn);
				    result.setDefaultModel("msg", "1");
				    result.setDefaultModel("goodid", id);
				 }
				 if (good_muns_id != null && !"".equals(good_muns_id)&&good_pard_id != null && !"".equals(good_pard_id)) {
             		GoodsMnus gmnus = goodsMnusDao.findById(GoodsMnus.class, Long.valueOf(good_muns_id));
             		GoodsMnus gmnus2 = goodsMnusDao.findById(GoodsMnus.class, Long.valueOf(good_pard_id));
             		result.setDefaultModel("goods_name", gmnus.getName());
             		result.setDefaultModel("good_parint_name", gmnus2.getName());
                 }
				 result.setDefaultModel("create_time", goodn.getCreate_time());
				 
			} catch (Exception e) {
				e.printStackTrace();
			}
             return result;
			}
		});
		return new ModelAndView("", modelMap);
	}
	//根据物品申请id删除信息
	@RequestMapping(value = "/toDeleteGoodsById")
	public ModelAndView toDeleteGoodsById(ModelMap modelMap, final BaseVo vo,
			final HttpServletRequest request, HttpServletResponse response)
					throws BaseException {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("id");
                
                if (id != null && !"".equals(id)) {
                	Boolean flag=goodsNewDao.delete(GoodsNew.class, Long.valueOf(id));
                	if(flag) {
                		result.setDefaultModel("msg", 1);
                	}else {
                		result.setDefaultModel("msg", 2);
                	}
                }else {
                	result.setDefaultModel("msg", 3);
                }
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}
	//保存物品申请总的
	@RequestMapping(value = "/add_goods_total_go")
	public ModelAndView add_goods_total_go(ModelMap modelMap, final BaseVo vo,
			final HttpServletRequest request, HttpServletResponse response)
					throws BaseException {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String goodid = request.getParameter("goodid");
				String goods_child_id = request.getParameter("goods_child_id");
				String all_words = request.getParameter("all_words");
				String msg = request.getParameter("msg");
				
				if (goods_child_id != null && !"".equals(goods_child_id)) {
					GoodsNew goodsNew=new GoodsNew();
					goodsNew.setGoods_child_id(goods_child_id);
					List<GoodsNew> goodsNews= goodsNewDao.findByExample(goodsNew);
					if(null!=goodsNews&&!goodsNews.equals("")) {
						for(GoodsNew goods:goodsNews) {
							goods.setImg_url(all_words);
							goods.setMsg(msg);
							goodsNewDao.update(goods);
						}
						result.setDefaultModel("msg", 1);
					}else {
						result.setDefaultModel("msg", 2);
					}
				}else {
					result.setDefaultModel("msg", 3);
				}
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}
	//采购物品列表
	@RequestMapping(value = "/toPurchaseList")
	public ModelAndView toPurchaseList(ModelMap modelMap, final BaseVo vo,
			final HttpServletRequest request, HttpServletResponse response)
					throws BaseException {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String audit_status = request.getParameter("audit_status");
				String center = request.getParameter("center");
				String goods_Names = request.getParameter("goods_Names");
				String sdate = request.getParameter("sdate");
				String edate = request.getParameter("edate");
				GoodsNew goodn = new GoodsNew();
				SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				
				try {
					if (audit_status != null && !"".equals(audit_status)) {
						goodn.setApply_status(Integer.valueOf(audit_status));
					}
					if (center != null && !"".equals(center)) {
						goodn.setCenter_name(center);
					}
					if (goods_Names != null && !"".equals(goods_Names)) {
						goodn.setItem_name(goods_Names);
					}
					if (sdate != null && !"".equals(sdate)) {
						goodn.setStartTime(sdf.parse(sdate+" 00:00:00"));
					}
					if (edate != null && !"".equals(edate)) {
						goodn.setEndTime(sdf.parse(edate+" 23:59:59"));
					}
					
					List<GoodsNew> list = goodsNewDao.getGoodsNewList(goodn);
					if(list!=null){
						for(GoodsNew gw : list){
							GoodsMnus gmnus = goodsMnusDao.findById(GoodsMnus.class, gw.getGood_muns_id());
							gw.setGoods_name(gmnus.getName());
						}
					}
					result.setDefaultModel("list", list);
				} catch (Exception e) {
					e.printStackTrace();
				} 
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}
	//采购申请编辑
	@RequestMapping(value = "/toQueryPurchase")
	public ModelAndView toQueryPurchase(ModelMap modelMap, final BaseVo vo,
			final HttpServletRequest request, HttpServletResponse response)
					throws BaseException {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				 String id = request.getParameter("id");
	                if (id != null && !id.equals("")) {
	                    GoodsNew goods = goodsNewDao.findById(GoodsNew.class, Long.valueOf(id));
	                    if(goods!=null){
	                    	GoodsNew goodsNew=new GoodsNew();
	                    	goodsNew.setGoods_child_id(goods.getGoods_child_id());
	                    	List<GoodsNew> goodsNewList=goodsNewDao.findByExample(goodsNew);
	                    	for(GoodsNew goodsNew2:goodsNewList) {
	                    		GoodsMnus gmnus = goodsMnusDao.findById(GoodsMnus.class, goodsNew2.getGood_muns_id());
	                    		GoodsMnus gmnus2 = goodsMnusDao.findById(GoodsMnus.class, goodsNew2.getGood_pard_id());
	                    		goodsNew2.setGoods_name(gmnus.getName());
	                    		goodsNew2.setGood_parint_name(gmnus2.getName());
	                    	}
	                    	result.setDefaultModel("goodsNewList", goodsNewList);
	                    }
	                }
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}
	//采购信息评价
	@RequestMapping(value = "/toPurchaseGoods")
	public ModelAndView toPurchaseGoods(ModelMap modelMap, final BaseVo vo,
			final HttpServletRequest request, HttpServletResponse response)
					throws BaseException {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("appraisalId");
				String purchasePerson = request.getParameter("purchasePerson");
				String purchaseGoods = request.getParameter("purchaseGoods");
				String purchaseMessage = request.getParameter("purchaseMessage");
				
				if (id != null && !id.equals("")) {
					GoodsNew goods = goodsNewDao.findById(GoodsNew.class, Long.valueOf(id));
					if(null!=goods) {
						GoodsNew goodsNew=new GoodsNew();
						goodsNew.setGoods_child_id(goods.getGoods_child_id());
						List<GoodsNew> goodsNews= goodsNewDao.findByExample(goodsNew);
						if(null!=goodsNews&&!goodsNews.equals("")) {
							for(GoodsNew good:goodsNews) {
								good.setPurchasePerson(Integer.valueOf(purchasePerson));
								good.setPurchaseGoods(Integer.valueOf(purchaseGoods));
								good.setPurchaseMessage(purchaseMessage);
								goodsNewDao.update(good);
							}
							result.setDefaultModel("msg", 1);
						}else {
							result.setDefaultModel("msg", 2);
						}
					}else {
						result.setDefaultModel("msg", 0);
					}
				}else {
					result.setDefaultModel("msg", 0);
				}
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}
	//采购信息评价
	@RequestMapping(value = "/toGoodsServiceAppraise")
	public ModelAndView toGoodsServiceAppraise(ModelMap modelMap, final BaseVo vo,
			final HttpServletRequest request, HttpServletResponse response)
					throws BaseException {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("appraisalId");
				String purchasePerson = request.getParameter("purchasePerson");
				String purchaseGoods = request.getParameter("purchaseGoods");
				String purchaseMessage = request.getParameter("purchaseMessage");
				
				if (id != null && !id.equals("")) {
					GoodsService goods = goodsServiceDao.findById(GoodsService.class, Long.valueOf(id));
					if(null!=goods) {
						goods.setPurchasePerson(Integer.valueOf(purchasePerson));
						goods.setPurchaseGoods(Integer.valueOf(purchaseGoods));
						goods.setPurchaseMessage(purchaseMessage);
						goodsServiceDao.update(goods);
						result.setDefaultModel("msg", 1);
					}else {
						result.setDefaultModel("msg", 2);
					}
				}else {
					result.setDefaultModel("msg", 2);
				}
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}
	//保存物品维修信息
	@RequestMapping(value = "/toSaveGoodsService")
	public ModelAndView toSaveGoodsService(ModelMap modelMap, final BaseVo vo,
			final HttpServletRequest request, HttpServletResponse response)
					throws BaseException {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("id");
				String goodsServiceType = request.getParameter("goodsServiceType");
				String serviceType = request.getParameter("serviceType");
				String serviceDetail = request.getParameter("serviceDetail");
				String image_url = request.getParameter("image_url");
				String username = request.getParameter("username");
				String centerName = request.getParameter("centerName");
				String purchaser = request.getParameter("purchaser");
				String msg = request.getParameter("msg");
				SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				
				GoodsService goodsService=new GoodsService();
				goodsService.setCenter(centerName);
				if(goodsServiceType != null && !goodsServiceType.equals("")) {
					goodsService.setGoodsServiceType(Integer.valueOf(goodsServiceType));
				}
				if(serviceType != null && !serviceType.equals("")) {
					goodsService.setServiceType(Integer.valueOf(serviceType));
				}
				if(serviceDetail != null && !serviceDetail.equals("")) {
					goodsService.setServiceDetail(Integer.valueOf(serviceDetail));
				}
				goodsService.setImage_url(image_url);
				goodsService.setUsername(username);
				goodsService.setAuditname(purchaser);
				goodsService.setMsg(msg);
				if (id == null || id.equals("")) {
					goodsService.setCreate_time(DateUtil.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
					goodsServiceDao.insert(goodsService);
					result.setDefaultModel("msg", 1);
				}else {
					GoodsService service= goodsServiceDao.findById(GoodsService.class, Long.valueOf(id));
					if(null!=service) {
						goodsService.setId(Long.valueOf(id));
						goodsServiceDao.update(goodsService);
						result.setDefaultModel("msg", 1);
					}else {
						result.setDefaultModel("msg", 2);
					}
				}
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}
	//物品维修列表
	@RequestMapping(value = "/toGoodsServiceList")
	public ModelAndView toGoodsServiceList(ModelMap modelMap, final BaseVo vo,
			final HttpServletRequest request, HttpServletResponse response)
					throws BaseException {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("id");
				String goods_state = request.getParameter("goods_state");
				String sdate = request.getParameter("sdate");
				String edate = request.getParameter("edate");
				String centerName = request.getParameter("centerName");
				SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				
				GoodsService goodsService=new GoodsService();
				try {
					
					goodsService.setCenter(centerName);
					if(null!=id&&!id.equals("")) {
						goodsService.setId(Long.valueOf(id));
					}
					if(null!=goods_state&&!goods_state.equals("")) {
						goodsService.setGoods_state(Integer.valueOf(goods_state));
					}
					if(null!=sdate&&!sdate.equals("")) {
						goodsService.setSdate(sdf.parse(sdate+" 00:00:00"));
					}
					if(null!=edate&&!edate.equals("")) {
						goodsService.setEdate(sdf.parse(edate+" 23:59:59"));
					}
					List<GoodsService> goodsServicesList= goodsServiceDao.getGoodsServiceListByInfo(goodsService);
					result.setDefaultModel("goodsServicesList", goodsServicesList);
					
				} catch (Exception e) {
					e.printStackTrace();
				} 
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}
	//获取物品维修分类详情
	@RequestMapping(value = "/getGoodsServiceDetail")
	public ModelAndView getGoodsServiceDetail(ModelMap modelMap, final BaseVo vo,
			final HttpServletRequest request, HttpServletResponse response)
					throws BaseException {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String serviceType = request.getParameter("good_mnus");
				
				GoodsServiceDetail serviceDetail=new GoodsServiceDetail();
				if(null!=serviceType&&!serviceType.equals("")) {
					serviceDetail.setServiceType(Long.valueOf(serviceType));
				}	
				List<GoodsServiceDetail> serviceDetails=goodsServiceDetailDao.findByExample(serviceDetail);
				result.setDefaultModel("serviceDetails", serviceDetails);
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	
	@RequestMapping(value = "/getAll_Tg_office")
	public ModelAndView getAll_Tg_office(HttpServletRequest request) {
		ModelAndView mav=new ModelAndView("");
		List<TgOffice> offices= tgOfficeDao.getAll_Tg_office();
		mav.addObject("offices",offices);
		return mav;
	}


}
